Docker Compose Bind Mount Issue

[Docker] Mounted Folder Becomes Empty After Redeploy in Docker Compose

If you’ve ever worked with Docker Compose and encountered a situation where your container suddenly can’t see any files in a previously working mounted folder, you’re not alone. This issue can be especially frustrating when everything seems to work fine on the initial deployment, only to break inexplicably after redeploy. The Problem When a folder is bind-mounted into a Docker container using Docker Compose, it works correctly during the initial deployment. However, after a redeploy — particularly when triggered by automation tools like Portainer — the mounted folder inside the container becomes empty. ...

Traefik routing issue between frontend and backend containers

[Docker/Traefik] Resolving Intermittent Frontend Loading and 504 Errors Behind a Traefik Reverse Proxy

We encountered a frustrating issue in our Dockerized app environment where the frontend service was intermittently failing to load, and backend API calls were stuck or returning 504 Gateway Timeout errors. Our infrastructure consists of: Frontend container (React app) Backend API container (Go server, accessible at /api/...) Database container (PostgreSQL) Traefik reverse proxy managing HTTPS termination and routing Despite having valid TLS certs and seemingly working routes, users experienced broken pages, incomplete frontend rendering, and stuck fetch requests to /api endpoints. ...

parse json arguments from command-line flags

[K8s/TLS] How to Create Local Kubernetes Cluster with Custom TLS Certificates

1. Introduction In this tutorial, we will walk through the steps to create a local Kubernetes cluster with TLS certificates configured. This setup ensures secure communication between your Kubernetes components. 2. Prerequisites Docker installed on your local machine kubectl installed kind installed OpenSSL installed for generating TLS certificates 3. Install kubectl (Ubuntu) curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" chmod +x kubectl sudo mv kubectl /usr/local/bin/ Verify the Installation You can verify the installation by running the following command: ...

traefik reverse proxy to non-containerized service

[Traefik/OCI] Exposing Internal Non-Containerized Services with Traefik on OCI: A Step-by-Step Guide

Traefik is a popular reverse proxy that can be used to expose internal containerized services to the public in a simple and intuitive way. However, if you want to expose internal services that are installed and configured directly on the host system instead of containerized, you may encounter some difficulties, particularly when using Oracle Cloud Infrastructure (OCI). This technical post will provide a step-by-step guide on how to expose internal non-containerized services to the public using Traefik on OCI. ...

[Docker/DinD] Empowering Local Development: Simulating Mass Containers and Docker Swarm Nodes with Docker-in-Docker (DinD)

Introduction In the realm of modern software development, the use of containerization has revolutionized the way applications are developed, tested, and deployed. Docker, a popular containerization platform, allows developers to create lightweight and isolated environments known as containers. However, when dealing with scenarios involving multiple containers that require isolated environments, testing and debugging can become quite a challenge. Enter Docker-in-Docker (DinD), a powerful tool that alleviates these pains and streamlines the development process. ...

Illustration: Docker container security - disabling SSH for production environments.

[Dockerfile] How to Prevent Docker Container from SSHing

While SSH is a valuable tool for debugging and testing Docker containers, enabling it in production environments is not recommended due to security concerns. To disable SSH in a Docker container, it’s advisable to remove the SSH server during the image building process. One way to accomplish this is to remove the SSH server during the Docker image building process. For example, if you’re using the alpine base image, you can use the following Dockerfile: ...

[OCI] Error: "iptables failed: iptables --wait -t filter -A DOCKER"

If you encounter the error messages shown below when attempting to run docker-compose up in OCI, a solution to the problem can be found in the following steps: failed to create network traefik_default: Error response from daemon: Failed to program FILTER chain: iptables failed: iptables --wait -I FORWARD -o br-5501386794d6 -j DOCKER: iptables v1.8.4 (legacy): Couldn't load target `DOCKER':No such file or directory Try `iptables -h' or 'iptables --help' for more information. (exit status 2) or ...

[Docker] Configure Custom TLS Certificates for Docker API Using Docker-in-Docker

Hey there! Have you ever wanted to configure custom TLS certificates for Docker API, but didn’t want to mess up your local Docker environment before you’re sure everything is working smoothly? Well, fear not! I’ve got a secret recipe for you that involves using Docker-in-Docker (DinD) to run a temporary Docker container with custom TLS certificates mounted. To get started, let’s say you already have your custom TLS certificates ready in the path `/tmp/certs``. You can run the following command to start a temporary Docker container with custom TLS certificates mounted: ...

[Nginx] Expose specified port for Nginx in Dockerfile

When we build a custom docker image based on nginx docker image, the default lisenting port will be 8080. However, port 8080 is a quite popular, so sometimes I want to give a different port for my service. The below snippet of code is the solution. FROM nginx COPY ./public/ /usr/share/nginx/html EXPOSE 1313 CMD ["/bin/sh", "-c", "sed -i 's/listen .*/listen 1313;/g' /etc/nginx/conf.d/default.conf && exec nginx -g 'daemon off;'"]

Docker Handbook (🚧Continuous Update)

1. Install docker and docker-compose on Ubuntu sudo apt-get update sudo apt install docker.io sudo apt install docker-compose 2. Configure rootless user to run docker sudo groupadd docker sudo usermod -aG docker $USER # Linux user can run below to activate the changes newgrp docker docker ps https://docs.docker.com/engine/install/linux-postinstall/ 3. List and delete images docker images docker iamge ls docker rmi <image_id_1> <image_id_2> 4. Check if the specific docker image exists IMAGE_ID=$(docker images | grep 'portainer/base' | awk '{ print $3 }') if [[ -n ${IMAGE_ID} ]]; then docker rm -f ${IMAGE_ID}; fi 5. Login remote registry # Default is dockerhub. username is docker hub id docker login # Login the specific registry docker login registry.private.com 6. Build image from Dockerfile docker build -t <user>/<repo>:<tag> -f Dockerfile . 7. Push the local image to remote registry docker image push <user>/<repo>:<tag> # Push to the private registry docker push registry.private.com/<repo>:<tag> 8. Add and view the docker volume # add volume docker volume create <volume_name> # view volume docker volume ls sudo ls /var/lib/docker/volumes 9. Check the volume detail docker volume inspect <volume_name> 10. Test docker container service connection with curl ping the http service ...

DigitalOcean Referral Badge
Sign up to get $200, 60-day account credit !