Small knowledge, big challenge! This paper is participating in theEssentials for programmers”Creative activities

Docker command

The command role
docker ps View the currently running container
docker ps -a View all container information (including non-running containers)[container details]
docker start / Open a container in Docker
docker stop / Stop a container in docker
docker kill / Force to kill a container
docker rm / Delete a container from docker
docker rmi Delete an image from docker (you can blur it with the container ID header)
docker rmi tag If the current two mirrors are the same (and the mirror IDS may be the same), a tag is appended to the deletion method
Docker run (here is a bunch of open parameters, need to improve the command) Run a container in Docker (can be opened with arguments)
docker images View all images in Docker
find / -name “default.conf” Find the location of the file whose name is default.conf
docker exec -it 404c92276210 /bin/bash Inside a container
systemctl status docker -l View the specified internal communication address
docker exec container_num nginx -s reload Restart nginx using Docker
Docker logs Container_num (or container name) View logs about a container
Docker inspect container_num View details about a container

Skill points

  • 172.16.1.6

Cheat point

  • After a service is enabled, you need to enable a port used by the service

    Ports that are not open to the outside world cannot be accessed

Understanding of Docker

  • Actually, I don’t know what docker is. Let’s just say it’s a large container

  • After creating a Docker, we can install various images in it.

  • After using the mirror run,

  • Docker concept creation sequence:

    docker -> image ->container

Docker file instructions

From specifies the base image run to execute the command, \

  1. Similar to the shellrun cmd\
  2. Similar to the execrun file arg\

Copy copy files add Copy and decompress files automatically (if you do not need to decompress files, just use copy) -add command will invalidate the image build cache, making the image build slow CMD container start parameters (container is a process, CMD can specify the process start parameters) Entrypoint 1. Volumn defines an anonymous volume. The -v parameter can be used to configure expose ports. Workdir specifies the working directory Healthcheck healthcheck healthcheck –intervalss=5s –timeout=3s CMD curl -fs http://127.0.0.1 | | exit 1 container after the operation, can through the docker container ls check container monitoring State docker inspect – format ‘{{json. State. The Health}}’ nginx | python – m Docker save {image} -o filename saves the image

Docker container

Docker container start {container} will start a terminated container and run the docker Container stop {container} Stop a running container docker container restart {container} restart a running container docker ps docker top {container} Docker attach {container} Docker attach {container} Docker attach {container} Docker exec it {container} bash exit does not delete the container docker container ls -a lists all containers docker export {containerId} > XXX. Tar local container cat everywhere XXX. Tar | docker import – test / {containerId} import from container snapshot file for mirror docker container rm Docker container Prune Deletes all containers in the terminated state

The mirror to find

Docker pull {{image}} push {{image}} push the image to the Docker hub

Build the mirror

Build a docker build from a local file -t nginx:v3 Build a docker build directly from a remote URL https://github.com/xxx#:11.1 Build a docker build using the given tar package http://xxx.tar.gz

Set up a private warehouse

An image can be based on the official Registry

docker run -d -p 5000:5000 -v /Users/nj/build/registry:/var/lib/registry registry

  1. Upload, download, and search images from private repositories

Commonly used parameters

-d Background run -I Interactive run -t Assign bash pseudo-terminal

docker run -d –name web -p 80:80 nginx:v3