Some basic operations of docker

 Docker installation is installed according to the official website documentation

  wget -qO- https://get.docker.com/ | sh
  usermod -aG docker your-username
  or
  wget -qO- https://get.docker.com/ | sh
  wget -qO- https://get.docker.com/gpg | sudo apt-key add -
Sometimes there will be a missing docker.sock file error, directly restart the docker service service docker restart
 
Use the following command to clean up all untagged local images
 docker rmi $(docker images --quiet --filter "dangling=true")
 docker rmi  $(docker images)
 docker rm $(docker ps -a -q)
 
To enter a running background container
 docker ps find container id
 docker top container id View container pid
or with docker inspect --format "{{ .State.Pid }}" <container>
 
  nsenter --target container pid --mount --uts --ipc --net --pid enter container
docker exec -it container bash
Users can either use docker load to import image storage files to the local image repository, or use docker import to import a container snapshot to the local image repository.
The difference between the two is that the container snapshot file will discard all historical records and metadata information (that is, only save the snapshot state of the container at that time), while the image storage file will save the complete record and be larger in size.
In addition, metadata information such as tags can be re-specified when importing from a container snapshot file.
 
To temporarily gain administrator privileges, gosu can be used instead of sudo.
docker inspect container View container information
docker run -d -P (then map the port)
 
Container names are unique. If you have named a container named web, when you want to use the name web again, you need to use docker rm to delete the previously created container with the same name.
If you add the --rm flag when executing docker run, the container will be deleted immediately after termination. Note that the --rm and -d parameters cannot be used at the same time.
docker run -t -i ubuntu:14.04 /bin/bash
Use the docker port container internal port to view the currently mapped port configuration, and you can also view the bound address. Container interconnection A child container can interconnect multiple parent containers
 
Docker does not customize the image for each container, so how to customize the hostname and DNS configuration of the container? The secret is that it uses dummy files to mount the 3 related configuration files coming to the container
Use the mount command in the container to see
 
remove bridge
$ sudo service docker stop
$ sudo ip link set dev docker0 down
$ sudo brctl delbr docker0
 
docker documentation

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326468159&siteId=291194637