<docker series> docker basic commands


1. View the commands that docker can run

[docker@localhost/]$ docker  --help

Commands:

   attach Attach to a runningcontainer #The attach connection under the current shell specifies the running image

   build Build an image from aDockerfile #Customize the image through Dockerfile

   commit Create a new image froma container's changes #Commit the current container as a new image

   cp        Copy files/folders fromthe containers filesystem to the host path

              #Copy the specified file or directory from the container to the host

   create Create a newcontainer #Create a new container, same as run , but do not start the container

   diff Inspect changes on acontainer's filesystem #View docker container changes

   events Get real time events from the server #Get container real-time events from the docker service

   exec Run a command in anexisting container #Run a command on an existing container

   export    Stream the contents of acontainer as a tar archive  

              #Export the content stream of the container as a tar archive [ corresponding to import]

   history Show the history of animage #Show a history of image formation

   images List images #List the current image of the system

   import    Create a new filesystemimage from the contents of a tarball 

              #Create a new filesystem image from the contents of the tar package [ corresponding to export]

   info Display system-wideinformation #Display system related information

   inspect Return low-levelinformation on a container #View container details

   kill      Kill a runningcontainer                      # kill指定 docker 容器

   load Load an image from a tararchive #Load an image from a tar package [ corresponding to save]

   login     Register or Login to thedocker registry server  

              #Register or log in to a docker source server

logout    Log out from a Dockerregistry server #Exit from the current Docker registry

   logs Fetch the logs of acontainer #Output the current container log information

   port      Lookup the public-facingport which is NAT-ed to PRIVATE_PORT

              #View the internal source port of the container corresponding to the mapped port

   pause Pause all processeswithin a container #Pause the container

   ps List containers #List the container list

   pull      Pull an image or arepository from the docker registry server

              #Pull the specified image or library image from the docker image source server

   push      Push an image or arepository to the docker registry server

              #Push the specified image or library image to the docker source server

   restart Restart a runningcontainer #Restart the running container

   rm Remove one or morecontainers #Remove one or more containers

   rmi       Remove one or moreimages                

              #Remove one or more images [ No container can use the image to delete, otherwise you need to delete the relevant container to continue or -f force deletion ]

   run       Run a command in a newcontainer

              #Create a new container and run a command

   save Save an image to a tararchive #Save an image as a tar package [ corresponding to load]

   search Search for an image on the Docker Hub #Search for images in docker hub

   start Start a stoppedcontainers #start container

   stop Stop a runningcontainers #stop the container

   tag Tag an image into arepository #Tag the image in the source

   top Lookup the runningprocesses of a container #View information about the processes running in the container

   unpause Unpause a pausedcontainer #Unpause the container

   version Show the docker versioninformation #View the docker version number

   wait      Block until a containerstops, then print its exit code  

              #Intercept the exit status value when the container is stopped

Run 'docker COMMAND --help' for moreinformation on a command.

 

2. Check the docker version

[docker@localhost/]$ docker  version

3. Search images

[docker@localhost/]$ docker search ubuntu

Fourth, view the local mirror

[docker@localhost/]$ docker images

5. View the current running container

[docker@localhost/]$ docker ps –a

6. Running the image

[docker@localhost/]$ docker run hello-world

7. Docker adjusts the running status

dockerstart|stop|kill|restart|pause|unpause|rm|commit|inspect|logs

dockerstart CONTAINER [CONTAINER...]

# run one or more stopped containers

dockerstop CONTAINER [CONTAINER...]

# Stop one or more running containers -t option can specify timeout

dockerkill [OPTIONS] CONTAINER [CONTAINER...]

# By default kill sends SIGKILL signal -s can specify the type of kill signal sent

dockerrestart [OPTIONS] CONTAINER [CONTAINER...]

# Restart one or more running containers -t option to specify timeout

dockerpause CONTAINER

# Pause a container for easy commit

dockerunpause CONTAINER

# continue the paused container

dockerrm [OPTIONS] CONTAINER [CONTAINER...]

# remove one or more containers

-f, --force=false Force removal ofrunning container

-l, --link=false Remove the specifiedlink and not the underlying container

-v, --volumes=false Remove the volumesassociated with the container

dockercommit [OPTIONS] CONTAINER [REPOSITORY[:TAG]]

# Submit the specified container as an image

-a, --author="" Author (e.g.,"John Hannibal Smith [email protected]")

-m, --message="" Commitmessage

-p, --pause=true Pause container duringcommit

# The default commit is the suspended state

dockerinspect CONTAINER|IMAGE [CONTAINER|IMAGE...]

# View container or image details

dockerlogs CONTAINER

# Output the specified container log information

-f, --follow=false Follow log output

# Similar to tail -f

-t, --timestamps=false Show timestamps

--tail="all" Output thespecified number of lines at the end of logs (defaults to all logs)

 

8. A diagram summarizing Docker's commands


Guess you like

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