sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io
docker --version
docker info
docker
docker <command> --help
docker images
docker pull <image_name>:<tag>
Example:
docker pull nginx:latest
docker build -t <image_name>:<tag> <path_to_dockerfile>
Example:
docker build -t myapp:1.0 .
docker rmi <image_id_or_name>
docker image prune -a
docker run <options> <image_name>:<tag>
Example:
docker run -d -p 80:80 --name my_nginx nginx:latest
docker ps
docker ps -a
docker stop <container_id_or_name>
docker start <container_id_or_name>
docker rm <container_id_or_name>
docker container prune
docker exec -it <container_id_or_name> <command>
Example:
docker exec -it my_nginx /bin/bash
docker logs <container_id_or_name>
docker network ls
docker network create <network_name>
docker network connect <network_name> <container_id_or_name>
docker network disconnect <network_name> <container_id_or_name>
docker network rm <network_name>
docker volume ls
docker volume create <volume_name>
docker volume rm <volume_name>
docker run -v <volume_name>:<container_path> <image_name>
Example:
docker run -d -v my_data:/app/data myapp:latest
# Use an official Python runtime as the base image
FROM python:3.9-slim
# Set the working directory in the container
WORKDIR /app
# Copy the current directory contents into the container at /app
COPY . /app
# Install any needed packages specified in requirements.txt
RUN pip install --no-cache-dir -r requirements.txt
# Make port 80 available to the world outside this container
EXPOSE 80
# Define environment variable
ENV NAME World
# Run app.py when the container launches
CMD ["python", "app.py"]
version: '3'
services:
web:
build: .
ports:
- "5000:5000"
redis:
image: "redis:alpine"
docker-compose up
docker-compose down
docker-compose logs
docker-compose up -d --scale <service_name>=<num_instances>
Example:
docker-compose up -d --scale web=3
docker swarm init
docker swarm join --token <worker_token> <manager_ip>:<manager_port>
docker node ls
docker stack deploy -c <docker-compose-file> <stack_name>
docker stack ls
docker stack rm <stack_name>
docker stats
docker inspect <container_id_or_name>
docker events
docker system df
docker system prune
docker top <container_id_or_name>
docker exec -it <container_id_or_name> /bin/sh
2024 © All rights reserved - buraxta.com