Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

566
Visualizações
Docker compose with subdirectory and live reload

I created an app using create-react-app and set up docker compose to set up the container and start the app. When the app is in the root directory, the app starts and the live reload works. But when I move the app to a subdirectory, I can get the app to start, but the live reload does not work.

Here's the working setup:

Dockerfile

FROM node:7.7.2

ADD . /code

WORKDIR /code

RUN npm install

EXPOSE 3000

CMD npm start

docker-compose.yml

version: "2"

services:
  client:
    build: .
    ports:
      - "3000:3000"
    volumes:
      - .:/code

Directory structure

app
- node_modules
- docker-compose
- Dockerfile
- package.json
- src
- public

Here's the structure that I would like:

app
- server
- client
  / node_modules
  / Dockerfile
  / package.json
  / src
  / public
- docker-compose.yml

I've tried every variation that I can think of, but the live reload will not work.

The first thing I had to do was change the build location:

version: "2"

services:
  client:
    build: ./client
    ports:
      - "3000:3000"
    volumes:
      - .:/code

Then I got an error when trying to run docker-compose up:

npm ERR! enoent ENOENT: no such file or directory, open '/code/package.json'

So I changed the volume to - .:/client/code and rebuilt and ran the command and the app started, but no live reload.

Anyway to do this when the app is in a subdirectory?

about 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

There's no difference to the paths inside the container when you move your local directory. So you only need to change the local references.

The volume mount should come from ./client

version: "2"

services:
  client:
    build: ./client
    ports:
      - "3000:3000"
    volumes:
      - ./client:/code
about 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda