hristo-vrigazov / docker-cheatsheet

Quick docker commands

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Quick commands for docker

  • Run bash inside a container
docker run -it tsutomu7/python-opencv bash
  • Remove all docker containers
docker rm $(docker ps -a -q)
  • Stop all docker containers
docker stop $(docker ps -a -q)
  • Connect docker container to your display
docker run -it --env="DISPLAY" --env="QT_X11_NO_MITSHM=1" --volume="/tmp/.X11-unix:/tmp/.X11-unix:rw" tsutomu7/python-opencv
  • Connect docker container port to your port
docker run -it -p 1880:1880 --name mynodered nodered/node-red-docker
  • Copy current folder into docker container's home folder
docker cp . 61e6ed03aa66:/home/scientist/.
  • Run a container connected to your display with given name
xhost local:root
docker run -it --name opencv --env="DISPLAY" --env="QT_X11_NO_MITSHM=1" --volume="/tmp/.X11-unix:/tmp/.X11-unix:rw"  tsutomu7/python-opencv
  • Find the id of a container by name
sudo docker ps -aqf "name=opencv"
  • List all images
docker images
  • Remove all docker images
docker rmi -f $(docker images -a -q)
  • Remove a docker image
docker rmi ubuntu
  • Build a docker image by a Dockerfile
docker build -t example .
  • Run an image
docker run example
  • Tag an existing local image
docker tag e379ad0b10e0 hvrigazov/example:latest
  • Steps needed to create a docker image and push it to docker hub
  1. Go to docker hub site and create the repository, say 'hvrigazov/example'
  2. Create a Dockerfile locally and build it
  3. See the id of the image:
docker images
  1. Tag it:
docker tag e379ad0b10e0 hvrigazov/example:latest
  1. Login:
docker login
  1. Push
docker push hvrigazov/example

About

Quick docker commands

License:MIT License