How to fix docker container exiting with code 6?

时间:2019-04-08 13:14:50

标签: docker meteor docker-compose

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

  • ubuntu : ubuntu:18.04
  • nginx proxy : jwilder/nginx-proxy:alpine
  • mongo : mongo:latest
  • Plus my own meteor app locally.

Other

  • Meteor version : 1.8.1
  • Docker version : 18.09.3, build 774a1f4
  • Docker Compose version : 1.23.2, build 1110ad01

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

  • docker-compose.dev.yml
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.

  • Dockerfile.dev
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

  • I Stopped and removed all containers, removed all images, removed all networks, and rebuild everything.
  • I Checked my internet access (average ping: ~35ms).
  • I Tried different version of "Meteor js" (1.8.1, latest, 1.8.0.2) with the flag ?release=1.8.0.2 in the Dockerfile.dev part where I do && (curl https://install.meteor.com | sh) \.
  • I Tried to find some documentation about code 6 when a container is exiting but found nothing relevant.
  • It tried to look at logs but none were available for the exited app container xxxxxx_webapp : result empty.
  • I tried to start separately the xxxxxx_webapp container and had a weird result with docker run xxxxxxx_webapp.
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:

  • I removed and reinstall everything from docker.
  • I tried a previous version of the app, 3 weeks ago that was fully working.
  • I Tried everything except using another wi-fi. Could this works? I don't think so but it there is always a hope.

2 个答案:

答案 0 :(得分:1)

尽管我也从来没有发现退出代码6是什么,但我确实在我的设置中找到了原因。 事实证明我的环境是无效的,因为我不小心将其设置为一个不存在的分支。

docker-compose --verbose设置我正确的路径

答案 1 :(得分:0)

解决方案

我是这样从计算机上的docker卸载e-v-e-r-y-t-h-i-n-g的:

  

警告:请注意,通过此过程,您将丢失配置,图像和容器。

  • 首先,我使用:
  • 从“系统”中删除了未使用的数据。
sudo docker system prune
  • 然后,删除所有网络和卷:
sudo docker volume prune
sudo docker network prune
  • 然后,必须完全卸载docker:
apt-get remove --purge docker*
  • 然后我必须删除docker容器和图像:
rm -rf /var/lib/docker
  • 然后,删除配置文件..
rm -rf /etc/docker
rm /etc/systemd/system/docker.service
rm /etc/init/d/docker
  • 然后删除了osbolete和orphan软件包:
apt-get autoremove && apt-get autoclean
  • 然后更新和升级现有软件包
apt-get update && apt-get upgrade

最后从以下位置重新安装了docker和docker-compose:

然后在,我从git重新下载了我的项目,并使用docker-compose up -d重新安装了它:)

所以,我相信这是docker的配置问题。不幸的是,我从未对“退出代码6”找到明确的答案。

如果遇到同样的“退出代码6”问题,请随时分享您的解决方案。