Introduction to docker
The use of containers in docker makes the day-to-day life of the software developer easier, as it becomes very easy to upload services such as databases, messaging services, caching services and other important tools that we use on a daily basis and can be installed with simplicity and later removed after use.
In the initial demos we used MongoDB and RabbitMQ and so you should upload these two services to docker. If you already have one of the services running, simply change the credentials in the configuration file.
code /src/App/app/appsettings.json
Logging in to docker.
docker login -u <user> -p <password>
Starting containers in docker
A basic example involves at least one mongodb container and one RabbitMQ container. Copy the line below and run to start the container in docker.
Item | Tool | Command |
---|---|---|
1 | MongoDB | docker run --name mongodb -p 27017:27017 -e MONGO_INITDB_ROOT_USERNAME=mongoadmin -e MONGO_INITDB_ROOT_PASSWORD=LltF8Nx*yo -d mongo |
2 | RabbitMQ | Go to RabbitMQ Settings |
3 | MySQL | docker run --name mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=LltF8Nx*yo -d mysql:8.0 |
4 | SQLServer | docker run --name sqlserver -e “MSSQL_SA_PASSWORD=LltF8Nx*yo”-e “ACCEPT_EULA=Y” -p 1433:1433 -d mcr.microsoft.com/mssql/server |
5 | PostgreSQL | docker run --name postgresql -p 5432:5432 -e POSTGRES_PASSWORD=LltF8Nx*yo -d postgres:latest |
6 | Redis | docker run --name redis -p 6379:6379 -e REDIS_PASSWORD=LltF8Nx*yo -d redis |
7 | Kafka | Go to docker compose settings |
8 | Seq | docker run --name seq -d -p 5341:5341 -p 8000:80 --memory=500mb --memory-swap=500mb -e SEQ_CACHE_SYSTEMRAMTARGET=0 -e ACCEPT_EULA=Y datalust/seq |
9 | Zipkin | docker run --name zipkin -d -p 9411:9411 openzipkin/zipkin |
10 | Jaeger | docker run -d --name jaeger -e COLLECTOR_ZIPKIN_HOST_PORT=:9411 -e COLLECTOR_OTLP_ENABLED=true -p 6831:6831/udp -p 6832:6832/udp -p 5778:5778 -p 16686:16686 -p 4317:4317 -p 4318:4318 -p 14250:14250 -p 14268:14268 -p 14269:14269 -p 9411:9411 jaegertracing/all-in-one:1.44 |
11 | Keycloak | docker run -d --name keycloak -p 8080:8080 -e KEYCLOAK_ADMIN=admin -e KEYCLOAK_ADMIN_PASSWORD=admin quay.io/keycloak/keycloak:20.0.3 start-dev |
Stopping containers and removing docker images
In this topic, we present some basic docker commands to remove containers and even clean up all local images. The last option of prune is very useful for cleaning up all of docker.
Item | Command | Objective |
---|---|---|
1 | docker PS -A | Listing the Containers |
2 | docker stop mongoDB | Stopping a Container |
3 | docker rm mongoDB | Removing a Container |
4 | docker kill $(docker ps -a -q) | Stop All Containers |
5 | docker RM $(docker PS -a -Q) | Remove All Containers |
6 | docker RMI $(docker images -Q) | Remove All Images |
7 | docker system prune --volumes -f -a | Clean up multiple docker dependencies |