Docker container cannot copy file into volumeHow is Docker different from a virtual machine?Should I use Vagrant or Docker for creating an isolated environment?How to list containers in DockerHow to get a Docker container's IP address from the host?How to remove old Docker containersCopying files from Docker container to hostCopying files from host to Docker containerHow to copy Docker images from one host to another without using a repositoryFrom inside of a Docker container, how do I connect to the localhost of the machine?What is the difference between the `COPY` and `ADD` commands in a Dockerfile?
GFCI outlets - can they be repaired? Are they really needed at the end of a circuit?
How to Prove P(a) → ∀x(P(x) ∨ ¬(x = a)) using Natural Deduction
What reasons are there for a Capitalist to oppose a 100% inheritance tax?
Was the old ablative pronoun "med" or "mēd"?
What is an equivalently powerful replacement spell for the Yuan-Ti's Suggestion spell?
Why didn't Boeing produce its own regional jet?
Partial fraction expansion confusion
How to enclose theorems and definition in rectangles?
How can a day be of 24 hours?
Why is it a bad idea to hire a hitman to eliminate most corrupt politicians?
Why do I get negative height?
How to find if SQL server backup is encrypted with TDE without restoring the backup
Was the Stack Exchange "Happy April Fools" page fitting with the '90's code?
How to coordinate airplane tickets?
Is it a bad idea to plug the other end of ESD strap to wall ground?
Bullying boss launched a smear campaign and made me unemployable
How do I exit BASH while loop using modulus operator?
How to prevent "they're falling in love" trope
What is a Samsaran Word™?
how do we prove that a sum of two periods is still a period?
Implication of namely
How badly should I try to prevent a user from XSSing themselves?
Why are UK visa biometrics appointments suspended at USCIS Application Support Centers?
Am I breaking OOP practice with this architecture?
Docker container cannot copy file into volume
How is Docker different from a virtual machine?Should I use Vagrant or Docker for creating an isolated environment?How to list containers in DockerHow to get a Docker container's IP address from the host?How to remove old Docker containersCopying files from Docker container to hostCopying files from host to Docker containerHow to copy Docker images from one host to another without using a repositoryFrom inside of a Docker container, how do I connect to the localhost of the machine?What is the difference between the `COPY` and `ADD` commands in a Dockerfile?
I am pretty new to docker, so i might be doing something truly wrong
I need to share some files between docker containers, using a docker compose file
I have already created a volume like this
docker volume create shared
After that i can check the created volume
docker volume inspect shared
[
"CreatedAt": "2019-03-08T14:54:57-05:00",
"Driver": "local",
"Labels": ,
"Mountpoint": "/var/lib/docker/volumes/shared/_data",
"Name": "shared",
"Options": ,
"Scope": "local"
]
My docker-compose.yaml file looks like this
version: '3.1'
services:
service1:
build:
context: Service1
dockerfile: Dockerfile
restart: always
container_name: server1-server
volumes:
- shared:/shared
service2:
build:
context: Service2
dockerfile: Dockerfile
restart: always
container_name: server2-server
volumes:
- shared:/shared
volumes:
shared:
external: true
And the Dockerfile looks like this (just for testing purposes)
FROM microsoft/dotnet:2.2-sdk AS build-env
RUN echo "test" > /shared/test.info
When i issue a docker-compose up command i get this error
/bin/sh: 1: cannot create /shared/test.info: Directory nonexistent
If i modify the Dockerfile to this
FROM microsoft/dotnet:2.2-sdk AS build-env
WORKDIR /app
COPY *.csproj ./
RUN cp *.csproj /shared/
I get this error
cp: cannot create regular file '/shared/': Not a directory
Any ideas how to achieve this ?
docker docker-volume
add a comment |
I am pretty new to docker, so i might be doing something truly wrong
I need to share some files between docker containers, using a docker compose file
I have already created a volume like this
docker volume create shared
After that i can check the created volume
docker volume inspect shared
[
"CreatedAt": "2019-03-08T14:54:57-05:00",
"Driver": "local",
"Labels": ,
"Mountpoint": "/var/lib/docker/volumes/shared/_data",
"Name": "shared",
"Options": ,
"Scope": "local"
]
My docker-compose.yaml file looks like this
version: '3.1'
services:
service1:
build:
context: Service1
dockerfile: Dockerfile
restart: always
container_name: server1-server
volumes:
- shared:/shared
service2:
build:
context: Service2
dockerfile: Dockerfile
restart: always
container_name: server2-server
volumes:
- shared:/shared
volumes:
shared:
external: true
And the Dockerfile looks like this (just for testing purposes)
FROM microsoft/dotnet:2.2-sdk AS build-env
RUN echo "test" > /shared/test.info
When i issue a docker-compose up command i get this error
/bin/sh: 1: cannot create /shared/test.info: Directory nonexistent
If i modify the Dockerfile to this
FROM microsoft/dotnet:2.2-sdk AS build-env
WORKDIR /app
COPY *.csproj ./
RUN cp *.csproj /shared/
I get this error
cp: cannot create regular file '/shared/': Not a directory
Any ideas how to achieve this ?
docker docker-volume
RUN mkdir /shared
?
– Max♦
Mar 8 at 20:47
Thanks a lot @Max, that helped with the writing part; but now i need to read that stored data in another container; what should i do ? RUN mount or something ? because in the second container the problem is that i cannot mkdir the same directory
– jmiguel77
Mar 8 at 21:01
Could you expand yourdocker-compose.yml
to include the second service?
– Max♦
Mar 8 at 21:08
i edited the original post to reflect the second service, the second Dockerfile uses the same image and only does a RUN ls -ln /shared but /shared does not exists
– jmiguel77
Mar 8 at 21:12
i finally decided against my first approach and now am building the dependencies for the service in the same image, as a previous step to build the main application; this question should be closed now
– jmiguel77
Mar 11 at 15:14
add a comment |
I am pretty new to docker, so i might be doing something truly wrong
I need to share some files between docker containers, using a docker compose file
I have already created a volume like this
docker volume create shared
After that i can check the created volume
docker volume inspect shared
[
"CreatedAt": "2019-03-08T14:54:57-05:00",
"Driver": "local",
"Labels": ,
"Mountpoint": "/var/lib/docker/volumes/shared/_data",
"Name": "shared",
"Options": ,
"Scope": "local"
]
My docker-compose.yaml file looks like this
version: '3.1'
services:
service1:
build:
context: Service1
dockerfile: Dockerfile
restart: always
container_name: server1-server
volumes:
- shared:/shared
service2:
build:
context: Service2
dockerfile: Dockerfile
restart: always
container_name: server2-server
volumes:
- shared:/shared
volumes:
shared:
external: true
And the Dockerfile looks like this (just for testing purposes)
FROM microsoft/dotnet:2.2-sdk AS build-env
RUN echo "test" > /shared/test.info
When i issue a docker-compose up command i get this error
/bin/sh: 1: cannot create /shared/test.info: Directory nonexistent
If i modify the Dockerfile to this
FROM microsoft/dotnet:2.2-sdk AS build-env
WORKDIR /app
COPY *.csproj ./
RUN cp *.csproj /shared/
I get this error
cp: cannot create regular file '/shared/': Not a directory
Any ideas how to achieve this ?
docker docker-volume
I am pretty new to docker, so i might be doing something truly wrong
I need to share some files between docker containers, using a docker compose file
I have already created a volume like this
docker volume create shared
After that i can check the created volume
docker volume inspect shared
[
"CreatedAt": "2019-03-08T14:54:57-05:00",
"Driver": "local",
"Labels": ,
"Mountpoint": "/var/lib/docker/volumes/shared/_data",
"Name": "shared",
"Options": ,
"Scope": "local"
]
My docker-compose.yaml file looks like this
version: '3.1'
services:
service1:
build:
context: Service1
dockerfile: Dockerfile
restart: always
container_name: server1-server
volumes:
- shared:/shared
service2:
build:
context: Service2
dockerfile: Dockerfile
restart: always
container_name: server2-server
volumes:
- shared:/shared
volumes:
shared:
external: true
And the Dockerfile looks like this (just for testing purposes)
FROM microsoft/dotnet:2.2-sdk AS build-env
RUN echo "test" > /shared/test.info
When i issue a docker-compose up command i get this error
/bin/sh: 1: cannot create /shared/test.info: Directory nonexistent
If i modify the Dockerfile to this
FROM microsoft/dotnet:2.2-sdk AS build-env
WORKDIR /app
COPY *.csproj ./
RUN cp *.csproj /shared/
I get this error
cp: cannot create regular file '/shared/': Not a directory
Any ideas how to achieve this ?
docker docker-volume
docker docker-volume
edited Mar 8 at 21:10
jmiguel77
asked Mar 8 at 20:43
jmiguel77jmiguel77
485412
485412
RUN mkdir /shared
?
– Max♦
Mar 8 at 20:47
Thanks a lot @Max, that helped with the writing part; but now i need to read that stored data in another container; what should i do ? RUN mount or something ? because in the second container the problem is that i cannot mkdir the same directory
– jmiguel77
Mar 8 at 21:01
Could you expand yourdocker-compose.yml
to include the second service?
– Max♦
Mar 8 at 21:08
i edited the original post to reflect the second service, the second Dockerfile uses the same image and only does a RUN ls -ln /shared but /shared does not exists
– jmiguel77
Mar 8 at 21:12
i finally decided against my first approach and now am building the dependencies for the service in the same image, as a previous step to build the main application; this question should be closed now
– jmiguel77
Mar 11 at 15:14
add a comment |
RUN mkdir /shared
?
– Max♦
Mar 8 at 20:47
Thanks a lot @Max, that helped with the writing part; but now i need to read that stored data in another container; what should i do ? RUN mount or something ? because in the second container the problem is that i cannot mkdir the same directory
– jmiguel77
Mar 8 at 21:01
Could you expand yourdocker-compose.yml
to include the second service?
– Max♦
Mar 8 at 21:08
i edited the original post to reflect the second service, the second Dockerfile uses the same image and only does a RUN ls -ln /shared but /shared does not exists
– jmiguel77
Mar 8 at 21:12
i finally decided against my first approach and now am building the dependencies for the service in the same image, as a previous step to build the main application; this question should be closed now
– jmiguel77
Mar 11 at 15:14
RUN mkdir /shared
?– Max♦
Mar 8 at 20:47
RUN mkdir /shared
?– Max♦
Mar 8 at 20:47
Thanks a lot @Max, that helped with the writing part; but now i need to read that stored data in another container; what should i do ? RUN mount or something ? because in the second container the problem is that i cannot mkdir the same directory
– jmiguel77
Mar 8 at 21:01
Thanks a lot @Max, that helped with the writing part; but now i need to read that stored data in another container; what should i do ? RUN mount or something ? because in the second container the problem is that i cannot mkdir the same directory
– jmiguel77
Mar 8 at 21:01
Could you expand your
docker-compose.yml
to include the second service?– Max♦
Mar 8 at 21:08
Could you expand your
docker-compose.yml
to include the second service?– Max♦
Mar 8 at 21:08
i edited the original post to reflect the second service, the second Dockerfile uses the same image and only does a RUN ls -ln /shared but /shared does not exists
– jmiguel77
Mar 8 at 21:12
i edited the original post to reflect the second service, the second Dockerfile uses the same image and only does a RUN ls -ln /shared but /shared does not exists
– jmiguel77
Mar 8 at 21:12
i finally decided against my first approach and now am building the dependencies for the service in the same image, as a previous step to build the main application; this question should be closed now
– jmiguel77
Mar 11 at 15:14
i finally decided against my first approach and now am building the dependencies for the service in the same image, as a previous step to build the main application; this question should be closed now
– jmiguel77
Mar 11 at 15:14
add a comment |
1 Answer
1
active
oldest
votes
A Dockerfile contains instructions to create an image. After the image is built, the image can be run as a container.
A volume is attached when launching containers.
It thus makes no sense to use Dockerfile instructions to copy a file into a volume while building an image.
Volumes are generally used to share runtime data between containers, or to keep data after a container is stopped.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55070725%2fdocker-container-cannot-copy-file-into-volume%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
A Dockerfile contains instructions to create an image. After the image is built, the image can be run as a container.
A volume is attached when launching containers.
It thus makes no sense to use Dockerfile instructions to copy a file into a volume while building an image.
Volumes are generally used to share runtime data between containers, or to keep data after a container is stopped.
add a comment |
A Dockerfile contains instructions to create an image. After the image is built, the image can be run as a container.
A volume is attached when launching containers.
It thus makes no sense to use Dockerfile instructions to copy a file into a volume while building an image.
Volumes are generally used to share runtime data between containers, or to keep data after a container is stopped.
add a comment |
A Dockerfile contains instructions to create an image. After the image is built, the image can be run as a container.
A volume is attached when launching containers.
It thus makes no sense to use Dockerfile instructions to copy a file into a volume while building an image.
Volumes are generally used to share runtime data between containers, or to keep data after a container is stopped.
A Dockerfile contains instructions to create an image. After the image is built, the image can be run as a container.
A volume is attached when launching containers.
It thus makes no sense to use Dockerfile instructions to copy a file into a volume while building an image.
Volumes are generally used to share runtime data between containers, or to keep data after a container is stopped.
answered Mar 8 at 21:45
Boris van KatwijkBoris van Katwijk
1,05211022
1,05211022
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55070725%2fdocker-container-cannot-copy-file-into-volume%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
RUN mkdir /shared
?– Max♦
Mar 8 at 20:47
Thanks a lot @Max, that helped with the writing part; but now i need to read that stored data in another container; what should i do ? RUN mount or something ? because in the second container the problem is that i cannot mkdir the same directory
– jmiguel77
Mar 8 at 21:01
Could you expand your
docker-compose.yml
to include the second service?– Max♦
Mar 8 at 21:08
i edited the original post to reflect the second service, the second Dockerfile uses the same image and only does a RUN ls -ln /shared but /shared does not exists
– jmiguel77
Mar 8 at 21:12
i finally decided against my first approach and now am building the dependencies for the service in the same image, as a previous step to build the main application; this question should be closed now
– jmiguel77
Mar 11 at 15:14