# docker
# Build
docker build -t image .
# Docker Run
docker run -d -p 8080:80 --name notes myregistry/notes:v1
docker run -d -e ASPNETCORE_ENVIRONMENT='Local' -p 8080:80 --name api apiImage
docker run -it ubuntu # interactive
# Cleanup
docker rm -f $(docker ps -a -q) # Delete every container
docker rmi -f $(docker images -q) # Delete every image
docker image prune -f
# Networking
docker network ls # bridge is default
docker network inspect bridge
docker network create --driver bridge isolated_nw # create user defined network
docker run --network=isolated_nw -itd --name=container3 busybox # use run flag to specify network (bridge is default)
# Misc
docker exec -it [container] bash
docker attach [container]
docker port [container]
docker run -p 127.0.0.1:80:8080 ubuntu bash
docker stats [container]
Note
The last command binds port 8080 of the container to port 80 on 127.0.0.1 of the host machine.
docker run --expose 80 ubuntu bash
Note
This exposes port 80 of the container without publishing the port to the host system’s interfaces.
# Docker Hub
docker login -u username -p
# Run Samples
# Redis
docker run -d --name redis -p 6379:6379 -v c:/work/redis/redis.conf:/redis.conf redis redis-server /redis.conf
redis-benchmark -q -n 1000 -c 10 -P 5c
# MySQL
docker run --name local-mysql -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mysql:tag
# RabbitMQ
docker run -d --hostname rabbit-local --name rabbit-local -p 8080:15672 -p 5672:5672 rabbitmq:3-management