Docker command all

By admin at 2020-04-10 00:25 • 154次点击

Docker command all

apt-get install docker-ce # install docker

apt-get -y autoremove docker-*  #remove docker all

docker ps-a # view all containers on the host (physical server)

docker exec -it Debian /bin/bash # goes inside the running container,

docker exec -it demo4f34ddedd /bin/bash

Use the mirror ID to enter the inside of the running container, but the ID will change. It is recommended to use the name to enter the container

docker inspect Debian # to see the container's details, such as the IPAddress

docker pulls nginx # to take the nginx container image

docker pull debian:8 # pulls the container image of debian 8

docker search-s 10 debian # debian container images with search ranking greater than 10

docker search debian # simply searches for deian container images

docker run --privileged -- it debian: 8.3/bin/bash # add root rights to the container

docker run-p 8080:8080 -it debian: 8.3/bin /bash

# opens the Debian 8.3 container port map, which maps port 8080 of the container to port 8080 of the host

Docker run-p debian: 8.3/bin /bash

# specifies the IP port mapping for the container

docker run-p -it debian:8.3 /bin/bash

Open arbitrary network connections to container mappings

docker run-p 3399:3399 -p 555:777-p 6666: 6666-p 777:777 --name debian-it debian: 8.3/bin /bash

Multi-port mapping and granting terminal permissions, the first IP is the host's port and the second IP is the IP port inside the container.

Exit # exits the internal container terminal

docker start/restart/stop  id/name  # start, restart, stop the container

docker export f2054f7b52a7ed3 | gzip > debian8.3.tar.gz # container packs the backup

zcat debian8.3.tar.gz | docker import - debian nginx:1 # container import

docker save -o debian8.3.tar a38fabc72285 # container image clone

docker load - i debian8.3.tar # container image import

docker commit f2017b3a5ed4 debian: 1

Clone a debian:1 container image from IDf2017b3a5ed4 container image

docker rm [container ID] # removes the container

docker rmi [mirror ID] # removes the container image

docker rmi -f [mirror ID] # forces the violent removal of the container image


Docker, command

登录 后发表评论