Docker
Jump to navigation
Jump to search
I started with docker as that is the name I knew at that time. Moved to Podman as that should be more secure and light-weight. Most information is in the Podman page.
Docker is used to create containers. In a container system resources are separated from each other e.g. to create a development environment where the developer can experiment freely without the risk of jeopardizing the host system.
A dockerfile defines what will be in the docker image, running the image will create a container.
- Installation
apt install docker.io apt install docker-buildx
- This creates a working container with a python virtual environment
- Dockerfile in /etc/docker
FROM debian
LABEL name="Hans de Ridder"
RUN apt-get update
RUN apt-get -y install python3-full
RUN python3 -m venv /home/ubuntu/venv
ENV PATH="/home/ubuntu/venv/bin:$PATH"
RUN pip install pandas
CMD ["echo", "I'm alive"]
- docker build -t <name>:<tag> /etc/docker
- This builds the image with a name and a tag
- docker image ls
- List all existing images
- docker run -v <hostdir>:<containerdir> -it <image ID> bash
- Create the container and open a bash prompt in it. When leaving the shell the container is closed
- This way you can run any command in a container that only exists while the command is running.
- <hostdir> is mounted on <containerdir> which will be created automatically
- docker ps -a
- List all containers
- docker system prune
- Delete unused images and build caches
- docker system prune -a
- Delete unused images and all build cache