so i have downloaded Docker Desktop
and until now i have tested out containers and stuff just executing regular commands (docker ps, docker images..., docker run...) inside my zsh terminal and it works fine but now i am in a position where i want to create a directory inside docker host so that i can put my dockerfile
inside, but if i run mkdir directory-name
it is going to create the directory inside my mac not docker? so what command can i use to indicate that i want the directory to be created on docker not on my own mac machine?
Say you have the following directory structure:
.
├── Dockerfile
└── simple-web-app
Your Dockerfile:
FROM scratch
ADD simple-web-app simple-web-app
Then you would run
docker build .
While your docker container is running, you can start a new shell session inside using docker exec
.
docker exec -it mycontainer bash
-i
means interactive - so you can type -t
allocates a pseudo-TTY - just know that you need the argument Then inside this bash, you can create folders and files all you want and they will be placed inside your running container. Note that whenever you remove the container (eg to update its image), these changes will be entirely lost . For persistence, use docker volumes .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.