Today we are going to learn how to run your first docker container.
I am assuming that you have already downloaded and installed docker desktop on your machine. If you haven't downloaded the docker then you use below link to download.
https://www.docker.com/products/docker-desktop
Now follow below instructions:
Open docker desktop on your machine. Make sure docker is running.To insure that docker is installed correctly run below command to check the version:
docker -v
docker pull alpine
Above command will download the Alpine image from dockerhub to your system.
docker image ls
docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
alpine latest bb3de5531c18 2 weeks ago 5.34MB
You can check image name along with image id and size it's taking on system.
Now lets run our first container by this command:
docker run -it alpine /bin/sh
-it is interactive mode, alpine is image name, /bin/sh is shell.
docker run -it alpine /bin/sh
/ #
Now type any linux command to see if you are inside linux.
/ # pwd
/
/ # whoami
root
/ # ls
bin dev etc home lib media mnt opt proc root run sbin srv sys tmp usr var
/ #
Wow! we have successfully started our container.
Note: If you think this helped you and you want to learn more stuff on devops, then I would recommend joining the Kodecloud devops course and go for the complete certification path by clicking this link
No comments:
Post a Comment