Docker container: exit code 1 but no error message

Viewed 2403

I have a simple Angular project (currently just the result of ng new ...) inside a docker container. The container is running the command ng build --watch to rebuild on source code changes. A separate docker container runs Nginx to allow me to view the result. The basic mechanics of all this appear to be working fine: I can edit source code, hit refresh in the browser and see the changes.

When I stop the containers, the nginx container exits cleanly, but the angular contain exits with status 1. There is no error message to help me figure out what the error is.

Dockerfile

FROM node:lts-alpine
RUN apk --no-cache add less bash jq curl wget zip git openssh
WORKDIR /app

docker-compose.yml

version: "3.7"

services:

  nginx:
    image: nginx:stable-alpine
    restart: always
    ports:
      - 8080:80
    volumes:
      - ./src/admin/build:/var/www
      - ./nginx.conf:/etc/nginx/conf.d/default.conf

  admin:
    image: angular # Custom image
    build: .
    working_dir: /app
    command: sh -c "yarn && yarn run watch" # "watch" = "ng build --watch"
    volumes:
      - ./src/admin:/app
$ docker-compose up -d
$ docker-compose stop
$ docker inspect admin_1 | jq '.[0].State'
{
  "Status": "exited",
  "Running": false,
  "Paused": false,
  "Restarting": false,
  "OOMKilled": false,
  "Dead": false,
  "Pid": 0,
  "ExitCode": 1,
  "Error": "",
  "StartedAt": "2020-09-30T01:10:29.063483594Z",
  "FinishedAt": "2020-09-30T01:10:49.396912972Z"
}

The docker logs show nothing unexpected, other than:

nginx_1 exited with code 0
admin_1 exited with code 1

Why isn't the angular container exiting cleanly with exit code 0?

0 Answers
Related