The first docker book study summary

  • Basic usage
    • Command to see if docker is working/info?
      • sudo docker info
    • List commands for docker containers?
      • docker ps
      • All containers -a, only look at the last -l, only return container ID-q
    • Create and name the interactive container?
      • sudo docker run --name my_container -i -t ubuntu /bin/bash
      • --Name specifies the name of the container, -i means that the container can be used interactively when STDIN is turned on, and -t means what base image is used
    • Start a stopped container?
      • sudo docker start my_container
      • sudo docker start aa38f0f4
      • Can be followed by container name or ID
    • Attach to the running container by name/ID?
      • sudo docker attach my_container
    • Create a guardian container?
      • sudo docker run --name daemon_container -d ubuntu /bin/sh -c "while true; do echo hello world; sleep 1; done"
    • View container logs?
      • sudo docker logs daemon_container
      • -f can be monitored, -tail 10 can see the last 10 lines
    • View the process in the container?
      • sudo docker top daemon_container
    • View the hardware statistics of the container?
      • sudo docker stats daemon_container
    • Start additional processes inside the container? Interactive/Background
      • Backstage:sudo docker exec -d daemon_container touch /etc/config
      • Interaction:sudo docker exec -t -i daemon_container /bin/bash
    • Stop a running container by name/ID?
      • sudo docker stop daemon_container
    • Program error docker restarts the container automatically?
      • sudo docker run --restart=always --name my_container -d ubuntu /bin/sh -c "while true; do echo hello world; sleep 1; done"
      • When –restart is always, the container will restart no matter what the exit code of the container is; set to on-failure to automatically restart only when the exit is non-zero. In addition, on-failure can set the number of restarts:--restart=on-failure:5
    • View container details?
      • sudo docker inspect my_container
    • Delete the container?
      • sudo docker rm 80483829fd
    • Create a mirror and bind ports?
      • sudo docker run --name daemon_container -p 8080:80 -d ubuntu /bin/sh -c "while true; do echo hello world; sleep 1; done"
  • Image build command
    • List docker images?
      • sudo docker images
      • You can add a specific mirror name
    • Pull the docker image?
      • sudo docker pull ubuntu:12.04
    • Find a mirror?
      • sudo docker search puppet
    • Log in to Docker Hub?
      • sudo docker login
    • Use the commit command to create a mirror step?
      • Run a container, such as:sudo docker run -i -t ubuntu /bin/bash
      • Run a bunch of commands in it
      • Use the exit command to exit the container
      • Submit a custom container: sudo docker commit 41a932fe hub_name/apache2
        41a...is the container ID, hub_name is the warehouse name, apache2 is the image name, and you can :webserveradd tags later
    • Use Dockerfile to create mirror steps?
      • Create Docker file
      • Build a new image command:sudo docker build -t="hub_name/static_web:v1" .
    • Push the image to Docker Hub?
      • sudo docker push static_web
    • Delete mirror?
      • sudo docker rmi jamtur01/static_web
  • docker compose
    • installation
      • sudo pip install docker-compose
    • Test whether it works
      • docker-compose --version
    • Startup/daemon startup
      • sudo docker-compose up
      • Daemon plus -d
    • List all services in docker-compose
      • sudo docker-compose ps
    • Out of service
      • sudo docker-compose stop
    • Delete service
      • sudo docker-compose rm

Guess you like

Origin blog.csdn.net/u011703187/article/details/107547653