User Tools

Site Tools


docker

Docker

Build

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 .

Run

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

Exec

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)
or
docker images -q |xargs docker rmi

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

Launch a MongoDB instance locally

docker run --name mongo -p 127.0.0.1:27017:27017 -d mongo

Launch a MySQL instance locally

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

Launch an ElasticSearch instance locally

docker run --name elasticsearch -p 127.0.0.1:9200:9200 -d elasticsearch
docker run --name kibana -e ELASTICSEARCH_URL=http://127.0.0.1:9200 -p 5601:5601 -d kibana:latest

docker.txt · Last modified: 2018/04/11 10:57 by jdx