0

I have a docker image running on port 3000 on my droplet on digital ocean.

I did some updates and created a new image and pushed it to my github packages.

I thought when I push the new image that the old one would just get overriden but Im getting an error saying

"Bind for 0.0.0.0:3000 failed: port is already allocated".

I run the following command when I get the above:

docker run -p 3000:3000 docker.pkg.github.com/UserName/Project/newImageName:1

This made me think that I could remove the old image and add the new one but that does not seem ideal but I have not found a command that can override/update to a new one.

Is this possible, and how?

ThunD3eR
  • 3,216
  • 5
  • 50
  • 94
  • When you run an image, an instance is created, which is as a container. Updating an image doesn't affect the container itself. – Amessihel Jan 13 '22 at 19:29
  • Is there a way to update the container? Just wondering if I can update this in a way without deleting the current container – ThunD3eR Jan 13 '22 at 19:32

1 Answers1

1

Run the image using --rm parameter (which removes the container upon exit).

docker run --rm -p 3000:3000 docker.pkg.github.com/UserName/Project/newImageName:1

After exiting (stopping the container) you can docker pull to get the latest version of the image and then re-run

Beppe C
  • 11,256
  • 2
  • 19
  • 41