Docker usefull commands
Docker Desktop is an easy-to-install application for your Mac or Windows environment that enables you to build and share containerized applications and microservices. Docker Desktop includes Docker Engine, Docker CLI client, Docker Compose, Docker Content Trust, Kubernetes, and Credential Helper.
Well, I’ve using docker for a while but not in my daily drive, so I have a problem. I always need to search for the same commands all the time. So that’s why this post was created for
How to install
https://docs.docker.com/desktop/mac/install/
Download, drag and drop, and run. Docker installation has changed over time, nowadays the process is now more guided.
Basic commands to get started.
Disclaimer: These commands were obtained from the docker Getting Started
Clone the repo and enter
1 | > docker run --name repo alpine/git clone https://github.com/docker/getting-started.git |
Build the docker image and run it
1 | docker build -t docker101tutorial . |
Share that image with anybody else
1 | docker tag docker101tutorial whistler092/docker101tutorial |
There are several commands here:
docker ps
allows you to see the running containers.docker ps -a
allows you to see all the containers.docker start
allows you to start a container.docker stop
allows you to stop a container.docker rm
allows you to remove a container.docker rmi
allows you to remove an image.docker images
allows you to see all the images.docker image rm
allows you to remove an image. That image cannot be used anymore.
Another command to get started.
docker build -t myuser/myimage .
Build an image based on the Dockerfile in the current directory. Tag is asmyuser/myimage
.docker run [image id or image tag]
Create and start a container based on the provided image id or tag.docker run -it [image id or image tag]
Create and start a container, but that flags also overrides the default command.docker ps
Print out information about all the running containers.docker ps -a
Print out information about all the containers.docker exec -it [container id] [cmd command]
Execute the given command in a running containerdocker logs [container id]
Print out the logs of a container.
Run postgresql
1 | > docker run --name postgresql-container -p 5432:5432 -e POSTGRES_PASSWORD=your_secret_password -d postgres |
to stop it and run it:
1 | > docker ps |
Now you can connect into your postgresql database
Run MSSQL Server
https://www.cloudiqtech.com/install-run-sql-server-docker-container-mac/
1 | docker pull microsoft/mssql-server-linux:2017-latest |
Useful links
https://medium.com/@bossjones/how-i-setup-a-raspberry-pi-3-cluster-using-the-new-docker-swarm-mode-in-29-minutes-aa0e4f3b1768#.dg9u9rbll | How I setup a Raspberry Pi 3 Cluster Using The New Docker Swarm Mode In 29 Minutes | by Malcolm Jones | Medium
https://docs.microsoft.com/en-us/virtualization/windowscontainers/about/ | About Windows containers | Microsoft Docs
https://skillsmatter.com/skillscasts/9146-building-a-bank-with-kubernetes | Building a Bank with Kubernetes | SkillsCast | 19th October 2016
https://www.percona.com/blog/2016/11/16/is-docker-for-your-database/ | Are Docker Containers Good for Your Database? - Percona Database Performance Blog
Nginx with reverse proxy
https://blog.florianlopes.io/host-multiple-websites-on-single-host-docker/ | Host multiple websites on a single host with Docker
https://github.com/nginx-proxy/nginx-proxy | nginx-proxy/nginx-proxy: Automated nginx proxy for Docker containers using docker-gen
https://github.com/ehazlett/interlock | ehazlett/interlock: Docker Event Driven Plugin System
http://jasonwilder.com/blog/2014/03/25/automated-nginx-reverse-proxy-for-docker/ | Automated Nginx Reverse Proxy for Docker ·
https://www.yannmoisan.com/docker.html | Playing with Docker and nginx : from multi-domain to multi-container | Yann Moisan
Containerizing apps
https://somakdas.medium.com/what-are-containers-and-how-to-containerizing-an-asp-net-mvc-application-using-docker-30931579f248 | What are containers and how to containerizing an Asp.Net MVC application using Docker | by Somak Das | Medium
https://dotnetthoughts.net/dockerize-an-existing-aspnet-mvc5-application/ | Dockerize an existing ASP.NET MVC 5 application | dotnetthoughts
https://www.youtube.com/watch?v=gO6jJX4rxW4 | Back to the Future: Containerize Legacy Applications - YouTube