I have created a docker image with required packages. I have run the docker image specifying the host and guest port along with the required volume mounting Example:
sudo docker run -it --name CONTAINERNAME -v /host:/guest -p
hostportno:guestportno
My container is up and running fine.
I am trying to migrate my container to a new docker image using docker-compose
.
I have created docker-compose.yml
file and specified the required parameters as shown below:
image: test1
ports
- "1234:123"
- "2000:223"
volumes:
- /home:/test
-container_name: dockercomposetest
working_dir: /test
command: /bin/bash
I am unable to migrate it using docker-compose.
I am getting issue as stated below:
Conflict. The name "test" is already in use by container eeedac72bb25.
You have to delete (or rename) that container to be able to reuse that
name.
Work around currently is I have to stop and remove the container and perform docker-compose up
.
Can I not restart/migrate a container using docker-compose with same name as I have started in normal docker run
process.
No, you can't have two containers with the same name. You'll have to pick a different name for the container_name
field. The previous container needs to be removed before you can re-use the name.
If you wanted Compose to treat the container as if it had created it, you have to set the container labels as Compose does. The easiest way to find these would be to have compose create a container (probably by removing the container_name
field), then using docker inspect
to view the labels.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With