docker-compose.yml – container with exited status on Ubuntu host

  docker, docker-compose

My docker-compose.yml:

version: "3.3"
      image: myapp:0
      build: .
      network_mode: host
    - './bin/cookie:/app/cookie'
    - './bin/logs:/app/logs'
    - './bin/warehouse:/app/warehouse'

Dockerfile doesn’t contain CMD and ENTRYPOINT, so when I execute commands in that order:

  1. docker build –tag myapp:0 .
  2. docker run -d -t myapp:0
  3. docker exec -it <container_id> /bin/bash

It works as expected.

For some reason the container is not working when using docker compose…

Commands order:

  1. docker-compose up -d –build
  2. docker-compose run -d build_and_run_service bash

What’s wrong?

Both cases work fine on Windows but not on Ubuntu…

FROM ubuntu:20.04 as runtime
LABEL description="Build and run container – myapp"

RUN apt-get update
RUN apt-get install -y software-properties-common
RUN apt-get install -y nano
RUN apt-get install -y wget
RUN apt-get install -y curl
RUN apt-get install -y make
RUN apt-get install -y build-essential
RUN apt-get install -y tcl zlib1g-dev libssl-dev tk libcurl4-gnutls-dev libexpat1-dev gettext dos2unix

# Compilers
RUN apt-get install -y gcc-10
RUN apt-get install -y g++-10

RUN rm /usr/bin/gcc    
    && ln -s /usr/bin/gcc-10 /usr/bin/gcc
RUN rm /usr/bin/g++ 
    && ln -s /usr/bin/g++-10 /usr/bin/g++
# Postgres dev
RUN sh -c 'echo "deb $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
RUN wget --no-check-certificate --quiet -O - | apt-key add -
RUN apt-get update
RUN apt-get install -y libpq-dev postgresql-server-dev-13

RUN cd /tmp      
    && wget --no-check-certificate     
    && tar -zxf openssl-1.1.1g.tar.gz      
    && cd openssl-1.1.1g      
    && ./config      
    && make      
    && make install      
    && rm /usr/bin/openssl      
    && ln -s /usr/local/bin/openssl /usr/bin/openssl      
    && ldconfig

RUN cd /tmp      
    && wget --no-check-certificate      
    && tar -zxf cmake-3.19.6-Linux-x86_64.tar.gz      
    && mv cmake-3.19.6-Linux-x86_64 /usr/local/      
    && ln -s /usr/local/cmake-3.19.6-Linux-x86_64/bin/cmake /usr/bin/cmake

RUN cd /tmp      
    && wget --no-check-certificate      
    && tar -zxf git-2.31.0.tar.gz      
    && cd git-2.31.0      
    && make prefix=/usr/local all    
    && make prefix=/usr/local install

RUN cd /tmp   
    && wget --no-check-certificate   
    && tar -zxf boost_1_75_0.tar.gz   
    && cd boost_1_75_0  
    && ./     
    && ./b2  
    && ./b2 install

VOLUME ["/app/cookie", "/app/logs", "/app/warehouse"]
COPY . /src

RUN cd /src 
    && mkdir build 
    && cd build
# Some building command

# Removes tmp
RUN cd /tmp 
    && rm -r *

Source: Docker Questions