B
B
by_EL2021-04-26 11:07:09
linux
by_EL, 2021-04-26 11:07:09

How to assign volume to a container?

How to assign several volumes (volume mapping) to a container?
Thanks

Answer the question

In order to leave comments, you need to log in

2 answer(s)
L
Larisa .•º, 2021-04-26
@barolina

from docker Use bind mounts

$ docker run -d \
  -it \
  --name devtest \
  --mount type=bind,source="$(pwd)"/target,target=/app \
  --mount type=bind,source="$(pwd)"/target,target=/app2,readonly,bind-propagation=rslave \
  nginx:latest

S
Sergey Sokolov, 2021-04-26
@sergiks

List a few. What is the difficulty?

docker run -it --rm --name QnA \
  -v /home/User/site1:/var/www/site1 \
  -v /home/User/site2:/var/www/site2 \
  -v /home/User/site3:/var/www/site3 \
  nginx

Do not add to an existing running raid. But you can commit it and start a new one with the added volume:
docker commit QnA  savedImage   # сохранит образ

docker run --name QnA_v2  \
  -v /home/User/site4:/var/www/site4 \
  savedImage

# убедиться, что всё норм. Остановить старый, пользоваться новым.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question