List of Docker Commands

General and image handling

docker version

Function: Check docker version running on docker server

  • Example:
docker version
1

docker info

Function: Check docker of docker server

  • Example:
docker info
1

docker pull

Function: Download image file

  • Usage: docker pull {resposity name}:{tag}
  • Example:
docker pull Ubuntu:12.04
1

docker images

Function: List imgae file

  • Example:
docker images
1

Containers

docker run

Function:

  1. check if the docker image is in the respository of docker server, if not, it will download from public respository
  2. create a container from the image, mount the writeable layer from read only layer of image.
  3. bridge a netork port form host to container
  4. assign a internal ip to container from pool.
  5. execute the user assigned program in container.
  6. stop the container after execution.
  • Usage: docker run {repository name}:{tag} {command to execute}
  • Example:
docker run ubuntu:14.04 /bin/echo 'Hello world'
1

Function: Run interactive Container

  • Usage: docker run –it {repository name}:{tag}
    -i = start interactive containter (inside container open the gate of input output)
    -t = create pseudo-TTY that attach to stdin and stdout (create a bridge for client to container)
  • Example:
docker run –it ubuntu:14.04
1

interactive

Function: Run docker in background

  • Usage: docker run –d {repository name}:{tag} {command}
  • Example:
docker run –d ubuntu:14.04 sleep 1000
1

background

Function: Remove the container automatically on container exits

  • Usage: docker run --rm {repository name}:{tag}
  • Example:
docker run –rm ubuntu:14.04 sleep 1
1

RemoveOnExit

Function: Specific the name of the container

  • Usage: docker run --name {custom name}{repository name}:{tag}
  • Example:
docker run –name hello_world ubuntu:14.04
1

name

Function: Run Docker with port mapping

  • Usage: docker run -it -p {host port}:{continer port} {repository name}:{tag}
  • Example:
docker run -it -p 8888:8080 tomcat:8.0
1

portmapping

docker ps

Function: check docker container

  • Usage: docker ps
  • Example:
docker ps
1

running

Function: check running docker container

  • Usage: docker ps -a
  • Example:
docker ps -a
1

pervious

docker rm

Function: remove docker

  • Usage: docker rm {container id}

docker inspect

Function: Display the low level information of container and image(ip address, image ID, log path...)

  • Usage: docker inspect {container id}

inspect

docker logs

Function: check the running log of the docker

  • Usage: docker logs {docker id}

logs

docker history

Function: check full set of layers that makes up the docker image

  • Usage: docker history {respository name}:{tag}

history

docker attach

Function: bring Background Docker to Foreground

  • docker attach {container id}

docker tag

Function: rename image

  • Usage: docker tag {image id} {new repository name}/{image using}: {new tag}
Last Updated: 2/10/2019, 1:31:35 AM