I am new about docker, so ,if any wrong thoughts come from me ,please point out it.Thanks~
I aim at running a web server that was developed by me ,or a team I belong to,in the docker.
So, I thought out three steps:
Have a image ,copy the web files into it,and run the container.so,I do the step below:
1- get a docker image.
I try like this : docker pull centos, so that I can get a image based on centos.Here, I did not care about the version of centos,of course, it's version is 6.7 or ,just taged:latest.
Here,I check the image by docker images,and I can see it like this:
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/centos latest d123f4e55e12 3 weeks ago 196.6 MB
So,I think this step successed.
2- try copying the files in local system to the container.
I stop at the path: /tornado,which had a folder named fordocker .The
fordocker contains the web-server files.
I try commonds like this(based on the guide):
docker cp fordocker/ d123f4e55e12:/web
But! Here comes the error:
Error response from daemon: No such container: d123f4e55e12
3- if I copy the files successfully,I could try like this:docker run -d centos xxx python web.py.
This step will come error?I don't know yet.
I searched a lot ,but do not explain the phenomenon.
It seemed that everyone,beside me ,use the commond would succes.
So,here comes the questions:
1- Is the method I thought out feasible? Must I create a images through profile?
2- Where comes the error if the method is feasible? Did the commond cp based on otherthings that I had not done?
3- What should I do if the method is not feasible?Create a image myself?
Have a good day~
You have docker images and docker container. That is different.
You pull or build images.
When you launch an image, it becomes a running container.
An image is not a running container, and so, you will not be able to copy a file inside an image.
I do not know if this what you want to do, but you may
1) launch an image
docker run ...
2) copy or modify a file
docker ps
shows your running container, and so you can
docker cp...
a file inside this running container
3) maybe save this modified image with
docker commit...
But usually, if you want to modify an image, you modify the Dockerfile, and so you can easily build a new image with such a command
docker build -t myuser/myimage:321 .
Notice the final dot, it means you use the Dockerfile that is local.
See for example a Dockerfile for Nginx
https://github.com/nginxinc/docker-nginx/blob/c8bfb9b5260d4ad308deac5343b73b027f684375/mainline/stretch/Dockerfile
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With