7/20/2016

Docker commonly used commands

Docker:
=======
d info
d inspect [container id]
d ps -a
d images
# Fetch image
d pull "image"
d rm [container id]
d rmi [image id]
d run -it # interactive tty
      --rm # remove after exiting
      -p 8888:8080 publish container port 8080 to 8888. To access: localhost:8888
      -v /home/liangzou:/home/liangzou # mounts the host drive to container
      --mac-address 70:85:c2:53:5d:4e # Make the mac address the passed in value.
d commit [container id] # create a new image from the existing docker
# d commit a5ab749ad736 harbor.prod.deepmap.ai/dazel/core-builddeps-dazel:ubuntu1804
d history # history of an image
d run -it --rm tomcat /bin/bash  # to check the container content
d attach --sig-proxy=false [container]
d search ubuntu # search for images
d tag [image id] name:tag # d tag 80ff9c14b9e0 core-builddeps-dazel:ubuntu1804
d exec # runs a new command in a running container.
d kill [container id]
# Delete all stopped containers
d rm `d ps -aq`

# Run a docker first
d run -it -d -v /var/lib/jenkins/workspace/:/root/user --mac-address 70:85:c2:53:5d:4e  776923679937.dkr.ecr.us-west-2.amazonaws.com/buildenv:latest
d exec `d ps -f ancestor=776923679937.dkr.ecr.us-west-2.amazonaws.com/buildenv:latest -q`  bash -c "cd /root/user/DeepMap-Presubmit && bazel build --verbose_failures --spawn_strategy=standalone --genrule_strategy=standalone  -- //experimental/..."
d cp [containerid]:/file/path /host/path

# To detach the tty without exiting the shell, use the escape sequence Ctrl+p + Ctrl+q

# Why does docker attach hang?
https://stackoverflow.com/questions/35573698/why-does-docker-attach-hang

If instead of enter you would start typing a command, you would not see the extra empty prompt line. If you were to run

$ docker exec -it --user root <container-ID-or-name> bash 

No comments: