OAPI TechBlog
Published in

OAPI TechBlog

My Docker Cheat Sheet With Simple Cases as Back-end Engineer

Photo by Simon Hrozian on Unsplash

#1. Commands

Working with Image :

  • docker build . : build image with no tag.
  • docker build . -t repository:tag : build image with tag name.
  • docker run --rm imageName: run container and auto destroy if stopped.
  • docker images : list all local docker images.
  • docker images --format “{{.Repository}}” : list all local docker images, and format this results. you can find the detail here.

Working with Container :

  • docker ps : show all running containers.
  • docker ps -a : show all stopped containers.
  • docker logs containerName : show container logs.
  • docker stop containerName : stop spesific container.
  • docker container prune : remove all stoped containers.
  • docker rm $(docker ps -a) : destroy all stopped containers.
  • docker exec -it containerName command : execute command in container.
  • docker stop container containerName : stop spesific container.
  • docker stop $(docker ps) : stop all running containers.

#2. Cases.

docker run --rm --name my-redis -p 6200:6379 redis
docker images --format “{{.Repository}} :{{.Tag}}”
docker build . -t awesome_project:v1-app -t awesome_project:v1-sidekiq
docker exec -it containerName cat config/local_env.yml

References

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store