Moff452
Moff452

Reputation: 131

How to fix docker container exiting with code 6?

Context

I am running a dockerized ubuntu for a Meteor (js) application with docker-compose file on my personnal computer. It is attached to a mongo DB container. And a nginx proxy container is running to make my development url secured with ssl (https).

Docker Images

Other

Problem

Since I stopped my containers with docker-compose down, when I restart them, my webapp container exits (with exit code 6) all the time. I didn't change the docker-compose files since my previous docker-compose -f docker-compose.dev.yml --verbose up

Error displayed by docker-compose -f docker-compose.dev.yml --verbose up

compose.cli.verbose_proxy.proxy_callable: docker inspect_container <- ('26d90365fe9a4b0c0eb24cb2c040aa43cf8ec207764f350b6273ee7362d9fe0e')
compose.cli.verbose_proxy.proxy_callable: docker wait <- ('26d90365fe9a4b0c0eb24cb2c040aa43cf8ec207764f350b6273ee7362d9fe0e')
urllib3.connectionpool._make_request: http://localhost:None "GET /v1.25/containers/26d90365fe9a4b0c0eb24cb2c040aa43cf8ec207764f350b6273ee7362d9fe0e/json HTTP/1.1" 200 None
urllib3.connectionpool._make_request: http://localhost:None "POST /v1.25/containers/26d90365fe9a4b0c0eb24cb2c040aa43cf8ec207764f350b6273ee7362d9fe0e/wait HTTP/1.1" 200 30
compose.cli.verbose_proxy.proxy_callable: docker wait -> {'Error': None, 'StatusCode': 6}
compose.cli.verbose_proxy.proxy_callable: docker inspect_container -> {'AppArmorProfile': 'docker-default',
 'Args': [],
 'Config': {'ArgsEscaped': True,
            'AttachStderr': False,
            'AttachStdin': False,
            'AttachStdout': False,
            'Cmd': ['meteor'],
            'Domainname': '',
            'Entrypoint': None,
            'Env': ['ENV_APP_SERVER_USERNAME=app',
...webappContainer exited with code 6

Result of docker ps -a

CONTAINER ID        IMAGE                        COMMAND                  CREATED             STATUS                      PORTS                                      NAMES
26d90365fe9a        xxxxxxxxxx_webapp            "meteor"                 23 minutes ago      Exited (6) 13 seconds ago                                              webappContainer
4073bbfe37cf        mongo                        "docker-entrypoint.s…"   39 minutes ago      Up 14 seconds               0.0.0.0:27017->27017/tcp                   mongoDBContainer
201f0a99d1cf        jwilder/nginx-proxy:alpine   "/app/docker-entrypo…"   2 hours ago         Up 2 hours                  0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp   nginx-proxy_nginx-proxy_1

Result of docker logs <container_id>

** none **

How ? The container will not even start. When I do docker run it works..

Source files

version: '3'
services:
  webapp:
    container_name: webappContainer
    env_file: .env
    environment:
      VIRTUAL_HOST: mysite.local
      VIRTUAL_PORT: ${PORT}
    build:
      context: ${CONTEXT}
      dockerfile: ${DOCKERFILE}...
    volumes:
      - ${VOLUME}:/usr/src/app
    expose:
      - ${PORT}
    networks:
      - dbAppConnector
      - default
    depends_on:
    - mongodb
  mongodb:...
    container_name: ${MONGO_CONTAINER_NAME}
    image: mongo
    restartmongodb: always
    env_file: .env
    ports:
    - "${MONGO_PORT}:${MONGO_PORT}"..
    networks:
      dbAppConnector:
    volumes:
    - mongo_volume:/data/db
    - ./docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d
volumes:
  mongo_volume:
networks:
  default:
    external:
      name: nginx-proxy
  dbAppConnector:


Note that when i do docker-compose config every .env variables are correctly displayed.

FROM ubuntu:18.04

# Set environment dir & copy files
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
COPY . /usr/src/app

# Make host.docker.internal accessible from outside the container (dev only)
# RUN ip -4 route list match 0/0 | awk '{print $3 "host.docker.internal"}' >> /etc/hosts

# Add user to run localy (dev only) the app
RUN addgroup meteoruser &&  useradd -rm -d /home/moff -s /bin/bash -g root -G sudo -u 1000 meteoruser

# Update distribution
RUN apt-get update -q && apt-get clean \
  # Install curl
  && apt-get install curl -y \
  # Install Meteor
  && (curl https://install.meteor.com | sh) \
  # Install node js
  && cd /usr/src/app \
  # replace vx.x.x by meteor node -e 'console.log("I am Node.js %s!", process.version);' output from my project folder.
  && bash -c 'curl "https://nodejs.org/dist/v8.15.1/node-v8.15.1-linux-x64.tar.gz" > /usr/src/app/required-node-linux-x64.tar.gz' \
  && cd /usr/local && tar --strip-components 1 -xzf /usr/src/app/required-node-linux-x64.tar.gz \
  && rm /usr/src/app/required-node-linux-x64.tar.gz \
  && cd /usr/src/app \
  && npm install

RUN cd /usr/src/app && chown -Rh meteoruser .meteor/local
EXPOSE 80
ENV PORT 80
WORKDIR /usr/src/app

USER meteoruser
CMD ["meteor"]

What I currently tried to fix the problem

This is your first time using Meteor!
Installing a Meteor distribution in your home directory.
Downloading Meteor distribution

It took 2+ minutes to finally show :

Retrying download in 5 seconds …
Retrying download in 5 seconds …
Retrying download in 5 seconds …
Retrying download in 5 seconds …

[[[[[ /usr/src/app ]]]]]

=> Started proxy.
=> Started MongoDB.

And so the container is running without exiting with the separate docker run command..

Reminder: everything was working fine for 4+ weeks, then suddenly I suspect my new internet connection being too slow (I moved from my parents house 1 week ago).

Could you guys please give some advises ? Is there any additional information I could provide to help you understand what I am missing ? Thanks in advance!

Edit

Other tries to make things work:

Upvotes: 3

Views: 7356

Answers (4)

Rakesh B E
Rakesh B E

Reputation: 892

Exit code 6 is thrown when you are pointing to the wrong branch. Check if you are pointing to a valid branch or not: docker-compose --verbose should solve your issue.

Also, I would suggest you to check the volume section in your code once.

Upvotes: 1

muya_
muya_

Reputation: 1008

TL;DR: If your use-case involves a deleted directory that's part of a volume, delete the docker volume, restart docker, then run compose up again


I was having the same issue, and it seemed related to one of my volumes.

I had the following definition in my docker-compose file:

  volumename:
    driver: local
    driver_opts:
      o: bind
      type: none
      device: "${PWD}/data/some/dir"

I had deleted and re-created the "${PWD}/data/some/dir" directory, and then started getting exit code 6 for the container that depended on the volume.

Things I tried:

  • Restart docker
  • Delete the volume (using the Docker Desktop UI) - this seemed to do the trick

Upvotes: 1

Dorothea Eggers
Dorothea Eggers

Reputation: 11

Though I never found out what exit code 6 is either, I did find it's cause in my setup. Turns out my environment was invalid because I had accidentally set it to a branch that didn't exist.

docker-compose --verbose up set me on the right path

Upvotes: 1

Moff452
Moff452

Reputation: 131

SOLUTION

I uninstalled e-v-e-r-y-t-h-i-n-g from docker on my computer like this :

Warning : Be aware that with this procedure you will lose your configuration, images, and containers.

  • First I removed unused data from the 'system' with :
sudo docker system prune
  • Then, removed all networks and volumes :
sudo docker volume prune
sudo docker network prune
  • Then, a complete uninstall of docker was necessary :
apt-get remove --purge docker*
  • then I had to remove the docker containers and images :
rm -rf /var/lib/docker
  • then, remove config files, ..
rm -rf /etc/docker
rm /etc/systemd/system/docker.service
rm /etc/init/d/docker
  • Then removed osbolete and orphan packages:
apt-get autoremove && apt-get autoclean
  • Then update and upgrade existing packages
apt-get update && apt-get upgrade

Finally reinstalled docker and docker-compose from :

And at the and I redownloaded from git my project, reinstalled it with docker-compose up -d :)

So, I believe this was a config problem with docker. Unfortunately I never found a clear answer on that "exit code 6" ..

Feel free to share your solution if you ever encounter the same "exit code 6" problem guys.

Upvotes: 0

Related Questions