V
V
VegasChickiChicki2021-11-27 19:20:36
Docker
VegasChickiChicki, 2021-11-27 19:20:36

How to create an anonymous volume in docker by giving it a path?

Can't deal with volumes in docker. I want to create two anonymous volumes when starting containers in order to pass the code from the local machine to the containers. One volume for one container, another for another.

I have this docker-compose.yml file:

version: "3"

services:
  client:
    build: client/
    command: npm run dev
    env_file:
      - ".env"
    ports:
      - "${CLIENT_PORT}:${CLIENT_PORT}"

  api:
    build: api/
    command: npm run dev
    env_file:
      - ".env"
    ports:
      - "${API_PORT}:${API_PORT}"


also in the project at the same level there are 2 folders: client and api, I need to throw them into the same places in the containers, I don’t understand how to specify the path correctly ...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Yarkov, 2021-11-27
@VegasChickiChicki

version: "3"

services:
  client:
    build: client/
    command: npm run dev
    env_file:
      - ".env"
    ports:
      - "${CLIENT_PORT}:${CLIENT_PORT}"
    volumes:
      - ./client:/client

  api:
    build: api/
    command: npm run dev
    env_file:
      - ".env"
    ports:
      - "${API_PORT}:${API_PORT}"
    volumes:
      - ./api:/api

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question