Why when I lift a container is it empty without data?

HI Everyone,

when I raise the container with the new image I get the setup. because ? . Why don’t you respect my data? Can someone help me please,

docker run -v /data/bitbucket:/var/atlassian/application-data/bitbucket --name=“bitbucket6” -d -p 7990:7990 -p 7999:7999 tlassian/bitbucket:7.21.4

i dont understood why not have data ?

I need help me, please please

Many many thanks.

Peter

Don’t worry, you will get help if we have time for one please :slight_smile: Or for none at all.

Docker will not remove your data. If you mount your folder to a wrong location in the container, than your data will be saved only to the container’s filesystem which will be removed. when you recreate the container. If it is not the case and you only lose data when you switch to a new image, then you should ask the maintainer of that image why it happens. If the new image has different parameters, that could also cause the problem.

You can find a link to the Atlassian support in the description:
https://hub.docker.com/r/atlassian/bitbucket

I don’t know this image, so I can’t tell you exactly what the problem is.

HI Rimelek

First of all, thank you very much for answering me. The link that you have given me is the one that I have followed but when I start the container following those instructions it starts but without data. I don’t know if I’m missing something in my container startup to reference the data so I don’t lose it

docker run -v bitbucketVolume:/var/atlassian/application-data/bitbucket --name="bitbucket" -d -p 7990:7990 -p 7999:7999 atlassian/bitbucket-server

I don’t know how to make the container boot with the new image and data when it starts.

Another thing in the link it says in step 2, I don’t understand it very well, it says that I have to copy
Copy existing to a docker volume directory, but Bitbucket-home is inside the container…how am I going to copy it?

Really thanks for the help me.

Many many thanks
Peter

Your command almost looks like the 1st example for the quick start section of the dockerhub description for the image:

docker run -v bitbucketVolume:/var/atlassian/application-data/bitbucket --name="bitbucket" -d -p 7990:7990 -p 7999:7999 atlassian/bitbucket

Note: the repo changed, the one you use is deprecated.

A container does not boot. It starts the entrypoint script which takes care of required preperations and starts the bitbucket server at the end. The example from above uses the named volume bitbucketVolume to store persistent data. The persistent data will remain in that volume until it gets deteleted. If you delete the container and create a new container that uses the same volume, the persistent data will be present. I mention it, because this is what is required when a new version of the image should be used: the old container needs to be removed and a new container using the same parameters needs to be created. The use of docker compose simplyfies that part a lot…

If something is unclear about the image description, please quote that parts - don’t just put them in your own words or try to describe - and thell us exactly which part of it you don’t understand.
Please quote parts of the original documentation and share with us what exactly you do

1 Like

Exactly as @meyay wrote. Please, quote the part from the description that you don’t understand.

If you use the same volume or the same bind mount for the new image, it should work. If it doesn’t, then the propblem is something with the app in the image which works differently. For example uses an other folder.

Hi everyone,
First of all thank you all for the help!
I go by parts:
-I have a container associated to a volume with an image.
What I want to do is upload the bitckubet version,
then;
First ; for the container.
second: I delete the image.
Third; I create a new volume and I put the path that the other volume had with the image with the new version.
The result is that everything starts correctly but it starts as if it were an installation from the beginning without taking the data.
How can I start the container so that it takes the old data?

I am trying and it works but it does not upgrade me but it starts as if it were a normal installation from the beginning;
docker run -v bitbucketVolume:/var/atlassian/application-data/bitbucket --name=“bitbucket” -d -p 7990:7990 -p 7999:7999 atlassian/bitbucket 8.3.1

bitbucketVolume → New volume
/var/atlassian/application-data/bitbucket → “homeb_bitbucket”
atlassian/bitbucket 8.3.1 → the new image that I have downloaded so that you can boot with the new version

Thank you very much for your patience and help.

note : I don’t know how to start the container with the new image with the data that the old volume had, how do I reference it at startup so that it respects the old data?

Regards,
Peter.

I am not sure why you did what you did, but the proper approach to “update” a container to use a new image is to remove the old container and create a new container based on the new image.

It shouldn’t matter if the named volume bitbucketVolume already exists or not

# 1. create the initial container based on image tag x
docker run -v bitbucketVolume:/var/atlassian/application-data/bitbucket --name=“bitbucket” -d -p 7990:7990 -p 7999:7999 atlassian/bitbucket 8.3.0

# 2. stop and remove container version x
docker stop bitbucket
docker rm bitbucket

# 3. create container based on image tag x+y reusing the already existing and previously in 1. used named volume
docker run -v bitbucketVolume:/var/atlassian/application-data/bitbucket --name=“bitbucket” -d -p 7990:7990 -p 7999:7999 atlassian/bitbucket 8.3.1

You already did step 1 of those (maybe with a different tag) already, and you also did step2. For the sake of consistency do not use docker rm --force if you want to have consistent data in the volumes the container used. So what’s left is step3, which uses exactly the name of the named volume as in step 1.

Please do not just describe what you did, always share the commands so we can actualy see how you did it, so we can identify what needs to be done differently.

Hi Everyone,

Everything you tell me works, but when it starts I have no data, just a clean installation with no data. The data I had before I don’t have. It’s like if I install a new program with nothing.

I observe is that when I launch the new image I see that a new volume is created

Regards,

I checked the Dockerfile of for the atlassian/bitbucket images and /var/atlassian/application-data/bitbucket is marked as VOLUME. Therefor, as long as you always use the same named volume mapped against that folder (a.k.a -v bitbucketVolume:/var/atlassian/application-data/bitbucket) and don’t remove the volume, a new container will continue to use the existing data.

This can only mean that you a) didn’t use the very same volume name for both containers or b) deleted the volume after stopping the container.

hi ,

ill try this with other version ,and I have deleted the other containers and I have not deleted any volume

docker run -v 7fe931e55f1d54a3aac020d138626cd58eeed61c4b28fb852cb5b06d200e12f0:/var/atlassian/application-data/bitbucket --name=bitbucket -d -p 7990:7990 -p 7999:7999 atlassian/bitbucket-server:7.21

takes me to home page → Bitbucket setup → i dont know why,
I don’t know why if I already told it the volume at startup, it’s as if it didn’t pay attention to it

docker volume ls
DRIVER VOLUME NAME
local 7fe931e55f1d54a3aac020d138626cd58eeed61c4b28fb852cb5b06d200e12f0

Thank you all very much for helping me,

I am puzzled, and I am not going to ask why I see an anonymous volume there.
Instead, I would suggest to directly work with docker compose.

I converted your docker run statement to a compose file.

Note: for an image update, the only thing you have to change is the tag at the end of the image line!

---

services:
  bitbucket:
    image:  atlassian/bitbucket:latest
    container_name: bitbucket
    restart: always
    networks:
      default: {}
    ports:
      - published: 7990
        target: 7990
        protocol: tcp
        #comment out if deployed as swarm stack
        #mode: ingress
    volumes:
      - type: volume
        source: bitbucket-data
        target: /var/atlassian/application-data/bitbucket
    environment:
      # your environments go here:
      # KEY: VALUE
volumes:
  bitbucket-data: {}

networks:
  default:
    name: bitbucket

Please copy the content with exactly the structure I used (do not replace and space characters with tabs, it will be break the yaml!) in a file called docker-compose.yml. Then deploy the compose file with docker compose up (add -d after up if you want to deploy it detached). If you do changes to the compose file, perform docker compose up -d again to deploy the changes. If you want to stop the container, just do docker compose stop and if you want to remove the container use docker compose down. The volume WILL remain, even if you do a stop or down.

update: fixed wrong comands, I accidently wrote docker run up instead of docker compose up

Thanks a lot , it works for me .

El El mié, 14 sept 2022 a las 18:14, Metin Y. via Docker Community Forums <notifications@docker.discoursemail.com> escribió: