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

264
Visualizações
Docker volumes - share file between two containers

I've got a Javascript helper file that contains general functions

Instead of duplicating it to both my containers (Node server and Vue frontend application) I thought I'll try creating a volume and sharing it between my containers So I've put it inside a folder called "Shared" in my root directory above my client and server folder which I turn into containers.

file system structure on my local machine:

root
--server
--client
--shared
--docker-compose.yml

Dockerfile

FROM node:latest as builder
WORKDIR /app
COPY package.json .
RUN npm install
COPY . ./
ENV PORT 8000
EXPOSE $PORT
RUN npm run build

Docker-compose.yml file

 client:
    build:
      context: ./client
      args:
        NODE_ENV: production
    volumes:
      - ./client:/app
      - /app/node_modules
      - type: bind
        source: ./shared
        target: /app/src/shared
    environment:
      - NODE_ENV=production

When I go into my container exec -it container_name bash and go into the directory i created, I can find the file there ! it was shared and is inside the container

But I cannot access it from my local machine - so I can't actually use it because its not actually created in a way that is useable for me when writing my code it just sits my in my container - inaccessible

Any ideas what I'm missing?

about 4 years ago · Juan Pablo Isaza
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