I am using docker-compose to manage Docker. Now suppose I want to update a source code in one of the Docker containers.

Can I do it using the exec but then how to copy the code from host to running container ?

Or is there any better solution to do the above task ?


It's a bad practice. You need to use Continuous Integration rebuild docker image (see Dockerfile) every time when source code changed.

  • can you suggest some suitable CI/ CD lib or software for the same ? Sep 28 '18 at 8:46
  • 1
    Drone CI, Jenkins, Travis CI Sep 28 '18 at 10:58

In terms of doing it once to verify how this is done you can use the docker cp command from the host machine -> https://docs.docker.com/engine/reference/commandline/cp/

But I agree with Meiram, this is bad practice. You want to be able to have the ability to revert back to a previous version of not only the code but also the container.

There is a very good tutorial here integrating Docker/DockerHub with Github, Jenkins, and even Sonarqube.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.