docker
runing as host
Get rid of all running containers
ENTRYPOINT vs CMD
- Use
ENTRYPOINT
to define the main command that should always run. - Use
CMD
to provide default arguments or commands that can be overridden.
#Example
FROM ubuntu:latest
# Set the entry point
ENTRYPOINT ["python3", "app.py"]
# Set default arguments
CMD ["--help"]
Docker logging
- Basic options
- –tail
- –head
- –since
- –until
- –follow
Checking the driver
This logs are stored in /var/lib/docker/containers/
- U can check them by
- In a particular container
[!Note]- Login drivers list
Docs
Creating a driver
[!example] Example file
Changing the driver
- –log-driver
docker run --log-driver local --log-opt max-size: 50m -p 80:80/tcp -d "betterstackcommunity/nginx-helloworld:latest"
[!bug] Log rotation isn’t set by default in json driver
Docker Network
[[Docker Netwroks.canvas|Docker Netwroks]]
Exposing vs publishing ports
- Exposing a port
- letting others know on which port the container is going to be
listening on
- This is for communicating with other containers, not with the outside world.
- letting others know on which port the container is going to be
listening on
docker container run \
--expose 80 \
--expose 90 \
--expose 70/udp \
-d --name port-expose busybox:latest sleep 1d
- Publishing ports
- Mapping the ports of the container with the host
Multi-stage docker images
Attach to the container
Docker compose
This file can be either yaml or json
- version (need to checuotu the last complibit version)
- It has to be a string!
- servives are whats beeing run
- u can also define ports with ports ## commands
- To start the server use docker-compose up
- To end the app type **docker compose down **
- Auto-reload
- cloud-int
- [podman]({{\< ref “posts/Linux/Docker/podman.md”>}})