Introduction to Docker

  1. install

  2. test installation: docker container run hello-world

  3. switch docker image repository

    1. sudo mkdir -p /etc/docker

    2. vim /etc/docker/daemon.json Replace the mirror with your own.

      1.    {
             "registry-mirrors": ["https://yxzrazem.mirror.aliyuncs.com"]
           }
    3. sudo systemctl daemon-reload; sudo systemctl restart docker

  4. add user to docker group (you can run docker commands without sudo)

    1. sudo groupadd docker
    2. sudo usermod -aG docker $USER
    3. newgrp docker
    4. verify: docker run hello-world
  5. restart docker service sudo service docker restart

  6. list docker images: docker images or docker image ls

  7. list containers: docker ps; list all containers: docker ps -a

  8. remove containers: docker rm <container id 1> <container id 2> ...; remove all stopped containers: docker rm $(docker ps -a -q status=exited) or docker container prune

  9. run container: docker run <container id>/<image id> <command>; run container with interface: docker run -it <container id>/<image id> bash