Docker 101: pull image, run a container and login into it


Continuing learning the basic commands for Docker, today we are going to try to pull an image, run the container with that image, and then login into the container. 

First, we can type this command to pull the image that we wish to run in our container, in our case we choose centos.

docker pull centos

Then after we pull the image, we can proceed to run the docker container, but as we are not running any application on it, is going to exit immediately afterward.

docker run centos
docker ps

Now we are going to run the centos image with the -it option to make us login into the container and make the container run the bash command

docker run -it centos bash


Important: When you exit the container, docker is going to exit the container. Why? Because you just login into it and run maybe a couple of commands, but the container was not running any service. 

Comments

Leave as a comment:

Archive