Docker is a platform that lets you package applications and their dependencies into lightweight, portable containers that can run consistently across different environments. Here are some of the commands that I routinely use.
Basic commands
Build an image:
docker build -t alango/node-hello .
Run the image:
docker run -it
--rm -d -p 8080:80
--name hello
-e WHO="laura" alango/node-hello
“ssh” into the container:
docker exec -t -i 7c21fb1cad24 /bin/bash
Push images to Docker Hub:
docker tag local-image:tagname new-repo:tagname
docker push new-repo:tagname
Starting a shell inside the container:
docker exec -it b403b7b43afe /bin/bash
List all containers.
docker ps
Docker on Azure
Create a container:
az container create
--resource-group enterpos
--name mycontainer
--image mcr.microsoft.com/azuredocs/aci-helloworld
--dns-name-label aci-demo-alanboy
--ports 80
az container show
--resource-group enterpos
--name mycontainer
--query "{FQDN:ipAddress.fqdn,ProvisioningState:provisioningState}"
--out table
https://docs.microsoft.com/en-us/azure/container-instances/container-instances-quickstart
Docker on AWS
https://docs.aws.amazon.com/AmazonECS/latest/developerguide/Welcome.html https://us-west-2.console.aws.amazon.com/ecs/home?region=us-west-2#/getStarted
more
docker stop: Stop a running container (send SIGTERM, and then SIGKILL after grace period) […] The main process inside the container will receive SIGTERM, and after a grace period, SIGKILL. [emphasis mine]
docker kill: Kill a running container (send SIGKILL, or specified signal) […] The main process inside the container will be sent SIGKILL, or any signal specified with option –signal. [emphasis mine]
https://www.digitalocean.com/community/tutorials/how-to-optimize-docker-images-for-production https://docs.docker.com/develop/dev-best-practices/