I am new to Docker and I have a question for it.
I have a docker container including my ASP.NET Core API project.
I would like to change some files in this project and then update it.
But I don’t wanna interfere or stop my project running.
Is it possible?
and if it is, how can i do that?
3
Answers
you can use
docker exec -it <container name> /bin/bash
to get a bash shell in the container. Then you can just run every commands to modify the project. Depending on the image of your container maybe the bin/bash can change to get a terminal.Containers are ephemeral by definition, I suggest you to modify your project and build it and start a new container and when it is running stop the old one.
I think you can also get into the constainer using:
then you can use the bash to modify the files that you want to modify, to get the container id you can type:
and you can find it under the CONTAINER ID section
I see two ways for you to do that. One is to get inside the container and the other one is to create a volume (and mount it), which will allow you to locally make a change and that same change will reflect in the container immediately.
This link might also help – it’s about storage in Docker.
These commands do not always work exactly this way, it always depends on your containers, but here you have some examples:
You can know your container ID and container name by doing
docker ps
The left side
/project_core_api
is in your machine and the right sidecore_api
will be the folder inside the container that will reflect all your changes in/project_core_api
.