containers

check version and info

1
2
docker --version
docker info

start/stop restart

1
2
3
sudo systemctl start docker
sudo systemctl stop docker
sudo systemctl restart docker

run a container from images

1
sudo docker run -d -p 7890:80 --name container's_name image

-d : run in detached mode;

-p : port mapping point;

—name : specify the container’s name

list containers and images

1
2
3
docker ps //list the containers that running
docker ps -a //list containers, include the stops
docker images -a //list images

stop or remove container

1
2
3
docker stop name_container
docker rm name_container
docker container prune // remove all stoped containers

start a container

restart first:

1
2
3

docker restart <container ID>

if start with interactive terminal:

1
2
3
4

docker exec -it abc1234def56(container ID) /bin/bash
docker exec -it (container name) /bin/bash

if not:

1
2
3
docker exec -it <container ID> /bin/bash # with interactive terminal

docker attach <container ID>

docker command line homepage

click here to come back to docker command line homepage.