┌────────────────────────┐ ┌───────────────────────┐
│ ┌───────────┐ │ │ ┌───────────┐ │
│ │ App │ │ │ │ App │ │
│ └───────────┘ │ │ └───────────┘ │
│ ┌────────┐ ┌────────┐ │ │ ┌────────┐ ┌───────┐ │
│ │ Libs │ │ Deps │ │ │ │ Libs │ │ Deps │ │
│ └────────┘ └────────┘ │ │ └────────┘ └───────┘ │
│ Container1 │ │ Container2 │
└────────────────────────┘ └───────────────────────┘
┌──────────────────────────────────────────────────┐
│ Docker │
└──────────────────────────────────────────────────┘
┌──────────────────────────────────────────────────┐
│ OS │
└──────────────────────────────────────────────────┘
┌──────────────────────────────────────────────────┐
│ Hardware Infrastructure │
└──────────────────────────────────────────────────┘
(Docker based architecture)
docker ps | List running containers |
---|---|
docker ps -a | List all containers |
docker ps -s | List running containers(with CPU / memory) |
docker images | List all images |
docker exec -it <container> bash | Connecting to container |
docker logs <container> | Shows container's console log |
docker stop <container> | Stop a container |
docker restart <container> | Restart a container |
docker rm <container> | Remove a container |
docker port <container> | Shows container's port mapping |
docker top <container> | List processes |
docker kill <container> | Kill a container |
docker start my-nginx | Starting |
docker stop my-nginx | Stopping |
docker restart my-nginx | Restarting |
docker pause my-nginx | Pausing |
docker unpause my-nginx | Unpausing |
docker wait my-nginx | Blocking a Container |
docker kill my-nginx | Sending a SIGKILL |
docker attach my-nginx | Connecting to an Existing Container |
docker inspect my-nginx | Inspecting Containers |
docker events my-nginx | Containers Events |
docker stats my-nginx | Container Resource Usage |
docker diff my-nginx | Lists the changes made to a container |
docker images | Listing images |
docker rmi nginx | Removing an image |
docker load < ubuntu.tar.gz | Loading a tarred repository |
docker load --input ubuntu.tar | Loading a tarred repository |
docker save busybox > ubuntu.tar | Save an image to a tar archive |
docker history | Showing the history of an image |
docker commit nginx | Save a container as an image. |
docker tag nginx eon01/nginx | Tagging an image |
docker push eon01/nginx | Pushing an image |
docker network rm MyOverlayNetwork | Removing a network |
docker network ls | docker network ls |
docker network inspect MyOverlayNetwork | Getting information about a network |
docker network connect MyOverlayNetwork nginx | Connecting a running container to a network |
docker run -it -d --network=MyOverlayNetwork nginx | Connecting a container to a network when it starts |
docker network disconnect MyOverlayNetwork nginx | Disconnecting a container from a network |
docker system prune | Cleans up dangling images, containers, volumes, and networks (ie, not associated with a container) |
docker system prune -a | Additionally, remove any stopped containers and all unused images (not just dangling images) |
docker image prune | Remove all dangling (not tagged and is not associated with a container) images |
docker image prune -a | Remove all images which are not used by existing containers |
docker container prune | Delete stopped containers |
docker search search_word | Search docker hub for images. |
docker pull user/image | Downloads an image from docker hub. |
docker login | Authenticate to docker hub |
docker push user/image | Uploads an image to docker hub. |
docker stop -f $(docker ps -a -q) | Stopping all containers |
docker rm -f $(docker ps -a -q) | Removing all containers |
docker rmi -f $(docker images -q) | Removing all images |
docker volume ls | Check volumes |
docker volume prune | Cleanup unused volumes |
Swiss army knife for offline environment container
FROM ubuntu:22.04
ARG DEBIAN_FRONTEND=noninteractive
WORKDIR /app
RUN apt-get update -y && \\
apt-get install --no-install-recommends \\
-y vim \\
nano \\
net-tools \\
curl \\
tcpdump \\
iftop \\
netcat \\
dnsutils \\
strace \\
htop \\
iputils-ping \\
nano \\
traceroute \\
nmap \\
iperf3 \\
python3 \\
python3-pip \\
htop \\
wget \\
tar \\
tshark \\
vnstat \\
bmon \\
network-manager \\
postgresql-client \\
mtr \\
tzdata
RUN wget <https://fastdl.mongodb.org/tools/db/mongodb-database-tools-ubuntu2004-x86_64-100.5.0.tgz> && \\
tar -zxvf mongodb-database-tools-ubuntu2004-x86_64-100.5.0.tgz && \\
mv mongodb-database-tools-ubuntu2004-x86_64-100.5.0/bin/* /usr/bin/ && \\
rm -rf mongodb-database-tools-ubuntu2004-x86_64-100.5.0.tgz mongodb-database-tools-ubuntu2004-x86_64-100.5.0
RUN apt install -y iproute2
COPY requirements.txt requirements.txt
COPY code .
COPY cronjob .
RUN pip3 install -r requirements.txt
ENV TZ=Europe/Istanbul
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone