Start nodejs app inside of traefik container

Hi all,

I want to start a nodejs app inside of a traefik container with following setup:

Dockerfile for my t14 image:

#FROM traefik:v3.0
FROM traefik:v3.0

ENV NODE_ENV=production

# install apk
RUN apk update && apk --no-cache add curl && apk --no-cache add bash
#

# install node
RUN apk add --update nodejs npm
RUN node --version
RUN npm --version
# end

COPY ./app /app
WORKDIR /app

CMD npm start

docker-compose.yml:

version: '3'

services:
  reverse-proxy:
    image: t14
    command:
      - "--api.insecure=true"
      - "--providers.docker=true"
      - "; bash -c 'npm start'"
    ports:
      - 80:80
      - 443:443
      # The Web UI (enabled by --api.insecure=true)
      - 8080:8080
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - ./traefik.yml:/etc/traefik/traefik.yml
      - ./ssl-certs:/ssl-certs
    networks:
      - traefik_web

But ive the problem that "bash -c 'npm start'" never gets executed. In other words my nodejs app never starts... Any hints / help regarding my problem?

Best regards

The idea of containers is isolation, so not to have applications with different dependencies in the same space.

As far as I know there is not even bash installed in the Traefik container. The Traefik container is highly customized for Traefik, not for other apps.

Furthermore you assume that Traefik terminates, so the second command is run afterwards. I would assume Traefik runs forever to enable output to stdout and stderr.

Check the container output for more info on what is happening.

Maybe you share what you want to achieve.