skip to Main Content

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


  1. 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.

    Login or Signup to reply.
  2. 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:

    docker exec -it {id_container} bash
    

    then you can use the bash to modify the files that you want to modify, to get the container id you can type:

    docker ps
    

    and you can find it under the CONTAINER ID section

    Login or Signup to reply.
  3. 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:

    1. To get inside the container

    docker exec -it container ID or container name bash

    You can know your container ID and container name by doing docker ps

    1. To create a container with a volume

    docker run -d –name my_container -v /project_core_api:/core_api my_image:tag

    The left side /project_core_api is in your machine and the right side core_api will be the folder inside the container that will reflect all your changes in /project_core_api.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search