Techno04335
Techno04335

Reputation: 1445

How can I restart a docker image instead of restarting docker?

I am trying to automate the deployment of a docker image on shinyproxy via bash scripting.

When I make changes to the dockerfile, I rebuild the dockerfile via:
sudo docker build -t test/app1

I have to restart docker via sudo service docker restart to see the changes.

Is there a faster one line commaned I can use for bash scripting to update the docker image to replace sudo service docker restart.

Thanks.

Upvotes: 0

Views: 212

Answers (1)

Qasim Sarfraz
Qasim Sarfraz

Reputation: 6442

You will have to (re)launch a new container with the latest image to see the changes. This can be automated in a script easily as below:

$ docker stop [OPTIONS] CONTAINER
$ docker rm [OPTIONS] CONTAINER
$ docker run [OPTIONS] NEW_IMAGE [COMMAND] [ARG...]

Docker has a comparatively fast startup time so don't be scared from launching new containers whenever you create a new image.

Upvotes: 3

Related Questions