View Docker Installation Information
docker info
Getting Docker mirrors
docker pull azraelrabbit/monupw
Creating a Docker Container
docker run --name monojexus -d -p 32022:22 -p 32080:80 -v /mydata:/data azraelrabbit/monupw
Run the Docker container in the way of the next process
sample_job=$(docker run -d monojexus /bin/sh -c "while true; do echo Docker; sleep 1; done")
Use the Docker logs command to view the current status of the job
docker logs $sample_job
Use Docker help to view Docker common commands
docker help
Stop Sample_job the background container
docker top $sample_job
Restarting a background container with a command
docker restart $sample_job
Stopping and removing containers
docker top $sample_job docker rm $sample_job
To save a container state as a mirror
docker commit $sample_job job1.1
View existing mirrors on this computer
docker images
Mirror Lookup
docker search <image-namge>
Viewing historical versions of mirrors
docker history <image-name>
Pushing mirrors to the mirrored warehouse
docker push <image-name>
Format of the library name
<user>/</image_name>
View the Docker version number, including client, server, dependent go, etc.
docker version
The default display is running container
docker ps
Displays the last created container, including the one that is not running
docker ps –l
Displays all container, including those that are not running
docker ps –a
View the container log, which is some output of the execution command
docker logs <container>
Delete one or more container
docker rm <container...>
Delete all the container
docker rm `docker ps -a -q`
Delete all the container
docker ps -a -q | xargs docker rm
Delete one or more image
docker rmi <image...>
Open/Stop/reboot container
docker start/stop/restart <container>
Start a container and go into interactive mode
docker start -i <container>
Attach a Running container
docker attach <container>
Use image to create container and execute the appropriate command, and then stop
docker run <image> <command>
Using image to create container and enter interactive mode, the login shell is/bin/bash
docker run -i -t <image> /bin/bash
Map the container port to the host's port
docker run -i -t -p
A container is fixed to a new image, followed by Repo:tag optional
docker commit <container> [repo:tag]
Look for a configuration file named Dockerfile under the path path that uses this configuration to generate a new image
docker build <path>
Ditto, you can specify repo and optional tag
docker build -t repo[:tag]
Using the specified dockerfile configuration file, Docker gets the content in stdin and uses this configuration to generate a new image
docker build - < <dockerfile>
See which port is mapped to the specified port of container, in fact, with Docker PS you can also see
docker port <container> <container port>
Change host Name
#docker run -it --hostname web jim/custom1 /bin/bash