User Tools

Site Tools


This is an old revision of the document!

Docker commands


docker build -t my-img .

docker build --no-cache --build-arg NODE_ENV=${NODE_ENV} -t my-img .

docker build -t my-img -f=my-dockerfile .


docker run -d -p 8082:8082 -v $(pwd)/data/logs:/data/logs -e 'NODE_ENV=dev' --name my-img my-img

docker run -it --name my-img my-img


docker exec -it my_image sh

Stop & Delete

docker ps -a

docker stop -t0 my-img

docker rm my-img
docker rm `docker ps -a -q`

Remove images

docker images

docker rmi --force $(docker images -q)
docker images -q |xargs docker rmi

# remove all unused images
docker rmi $(docker images --filter "dangling=true" -q --no-trunc)

Remove all volumes

docker volume rm $(docker volume ls -q --filter dangling=true)

Run a Python 3 Debian image locally

docker run -it --name python python:3.7.3-slim sh

Run a Node 14 image locally, and mount the current folder

docker run -it --name node14 node:14.17.5-bullseye-slim -v ~/mypath:/app sh

Launch a MongoDB instance locally

docker run --name mongo -p -d mongo

Launch a MySQL instance locally

docker run --name mysql -e MYSQL_ROOT_PASSWORD=yolo -e MYSQL_DATABASE=mydb -p -d mysql:5.6.39
mysql -pyolo -uroot -h -P 3306 mydb

Launch an ElasticSearch instance locally

docker run --name elasticsearch -p -d elasticsearch
docker run --name kibana -e ELASTICSEARCH_URL= -p 5601:5601 -d kibana:latest
docker.1634303522.txt.gz · Last modified: 2021/10/15 13:12 by jdx