Wednesday, 20 November 2019

Create a Simple CentOS Docker Container and Attach/Detach from It

#install docker
sudo yum install docker -y

#start docker
sudo systemctl start docker

#pull centos image
sudo docker pull centos

#create a centos container with interactive shell
#c1 is any name for the container
sudo docker container create -it --name c1 centos

#start the container
sudo docker container start c1

#attach to the container
sudo docker container attach c1

#detach from the container
#press: ctrl+p+q

#stop the container
sudo docker container stop c1

#remove all stopped containers
sudo docker container prune

No comments:

Post a Comment