FG
☁️ Cloud & DevOpsDocker

docker-compose hangs

Freshabout 19 hours ago
Mar 14, 20260 views
Confidence Score95%
95%

Problem

Description of the issue In a new server installation (on a VPS provided by OVH) running Ubuntu 18.x the Docker system works flawlessy and fast but docker-compose sometimes hangs indefinitely for no reason. And for every command, from version to ps, up, logs and so on. I tried everything regarding DNS and name resolution, even disabling systemd-resolved. When it works it is fast. When it hangs I can see the `/tmp/_Mxyz123123` directory created. Running with verbose hangs before any output. And then completes flawlessy. Context information (for bug reports) Output of `docker-compose version` [code block] Output of `docker version` [code block] Output of `docker-compose config` (Make sure to add the relevant `-f` and other flags) [code block] Steps to reproduce the issue 1. docker-compose <command> Observed result Sometimes hangs Expected result Run fast. Stacktrace / full error message No stacktrace but i managed to strace the behavior. [code block] Additional information Linux vps[omit] 4.15.0-48-generic #51-Ubuntu SMP Wed Apr 3 08:28:49 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux Ubuntu 18.04.2 LTS docker-compose installed with curl I have lot of other docker-compose environments working and this is the first time I see this behavior. Any idea on what to check or where to look?

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix – Awaiting Verification

Optimize Docker Compose Networking Configuration

Medium Risk

The hanging behavior of docker-compose on the new server installation may be due to improper DNS resolution or networking issues within the Docker environment. The creation of temporary directories like `/tmp/_Mxyz123123` suggests that docker-compose is attempting to resolve container names or network configurations but is unable to do so efficiently, leading to indefinite hangs.

Awaiting Verification

Be the first to verify this fix

  1. 1

    Check Docker Network Configuration

    Inspect the existing Docker network configurations to ensure there are no conflicts or misconfigurations that could lead to hangs. Use the command below to list all networks.

    bash
    docker network ls
  2. 2

    Create a Custom Docker Network

    If there are issues with the default bridge network, create a custom network for your docker-compose applications. This can help isolate the network traffic and improve DNS resolution.

    bash
    docker network create my_custom_network
  3. 3

    Update docker-compose.yml to Use Custom Network

    Modify your docker-compose.yml file to specify the custom network created in the previous step. This ensures that all containers use the same network and can resolve each other reliably.

    yaml
    version: '3'
    services:
      my_service:
        image: my_image
        networks:
          - my_custom_network
    networks:
      my_custom_network:
        external: true
  4. 4

    Disable IPv6 in Docker Daemon

    Sometimes, enabling IPv6 can cause issues with DNS resolution in Docker. Edit the Docker daemon configuration file to disable IPv6 by adding the following lines.

    json
    {
      "ipv6": false
    }
  5. 5

    Restart Docker Service

    After making changes to the Docker configuration, restart the Docker service to apply the new settings. This can help clear any existing network issues.

    bash
    sudo systemctl restart docker

Validation

Run docker-compose commands such as 'docker-compose up' or 'docker-compose ps' and check if they complete without hanging. Monitor the network performance and check for any temporary directories in /tmp.

Sign in to verify this fix

Environment

Submitted by

AC

Alex Chen

2450 rep

Tags

dockerdocker-composecontainerskind/bug