Pushed Images to Docker Hub Using Docker Compose, But Can't Find Them

Hello,

I didn’t know how to configure the image and repository settings, so I didn’t set them up initially. I proceeded to build, push, and pull the images using Docker Compose. All commands executed successfully, but now I’m unsure where my pushed files went and from where I pulled them. I’m concerned whether they went to a public repository, potentially causing a data leak, or if they were stored in a private or temporary location. Additionally, I’m puzzled as to why I can’t see them on Docker Hub.

My Docker Compose File:

version: '3.7'

services:
  web:
    build:
      context: ..
      dockerfile: docker/Dockerfile
    container_name: sozluk_backend
    volumes:
      - static_volume:/usr/src/app/static:rw
      - media_volume:/usr/src/app/media:rw
    expose:
      - 5432
    env_file:
      - ../conf/django.env
    depends_on:
      - db

  nginx:
    build:
      context: ..
      dockerfile: docker/nginx/Dockerfile
    container_name: sozluk_nginx
    volumes:
      - static_volume:/home/app/web/static
      - media_volume:/home/app/web/media
    ports:
      - "80:8080"
    depends_on:
      - web

//4 more container settings...

My github/workflows/Deployment.yml :

 steps:
      - name: Checkout code
        uses: actions/checkout@v2

      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v1

      - name: Login to Docker Hub
        uses: docker/login-action@v1
        with:
          username: ${{ secrets.DOCKER_USERNAME }}
          password: ${{ secrets.DOCKER_PASSWORD }}

      - name: Set up Docker Compose
        run: |
            sudo curl -L "https://github.com/docker/compose/releases/download/v2.5.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
            sudo chmod +x /usr/local/bin/docker-compose

      - name: Build and Push Docker images
        run: |
          docker-compose -f docker/docker-compose.yml build
          docker-compose -f docker/docker-compose.yml push

      - name: Copy Docker Compose file to server
        uses: appleboy/scp-action@master
        with:
          host: ${{ secrets.SERVER_HOST }}
          username: ${{ secrets.SERVER_USER }}
          key: ${{ secrets.SSH_PRIVATE_KEY }}
          source: "docker/docker-compose.yml"
          target: "/var/www/prod"

      - name: Deploy on server
        uses: appleboy/ssh-action@master
        with:
          host: ${{ secrets.SERVER_HOST }}
          username: ${{ secrets.SERVER_USER }}
          key: ${{ secrets.SSH_PRIVATE_KEY }}
          script: |
            cd /var/www/prod
            docker-compose -f docker/docker-compose.yml pull
            docker-compose -f docker/docker-compose.yml up -d

Thanks.

Since pushing images requires logging in, if you haven’t done it, there is no way you pushed your images unless you tagged those to push to a private registry without authentication. Somehow I doubt that you could do that. so not likely. The compose services you showed in the compose file have build configs without image name, so even if you logged in to Docker Hub, the images could not have been pushed as you don’t have push access to docker.io/library/<COMPOSE_PROJECT_NAME>_<SERVICENAME> which would be the default without setting a repository owner in the tag.

If you had other images you didn’t show in the compose file and you set the tags to match your own repository and you logged in, then you might have pushed your images.

I think it is more likely there was nothing to push so the output was just empty and nothing happened.

thank you for your answer however

this is interesting because when I look at the GitHub action log file, I successfully logged in, my files were successfully pushed to a certain point after the build process, then an SSH connection was established to the server, and a successful pull operation was performed. However, during the compose up process, the operation was canceled because a directory was missing, and it moved to the “Post Login to Docker Hub” step.

“Post Login to Docker Hub”

##[debug]..Evaluating String:
##[debug]..=> 'DOCKER_USERNAME'
##[debug]=> '***'
##[debug]Result: '***'
##[debug]Evaluating: secrets.DOCKER_PASSWORD
##[debug]Evaluating Index:
##[debug]..Evaluating secrets:
##[debug]..=> Object
##[debug]..Evaluating String:
##[debug]..=> 'DOCKER_PASSWORD'
##[debug]=> '***'
##[debug]Result: '***'
##[debug]Loading env
Post job cleanup.
/usr/bin/docker logout 
Removing login credentials for https://index.docker.io/v1/
##[debug]Node Action run completed with exit code 0
##[debug]Finishing: Post Login to Docker Hub

the operations were performed, and then the “Post Set up Docker Buildx” operation was performed, where the following was done:

Post job cleanup.
::group::BuildKit container logs
BuildKit container logs
  /usr/bin/docker logs buildx_buildkit_builder-28b5b173-9f38-4a20-a162-268db18a288f0
  time="2024-08-25T23:17:10Z" level=info msg="auto snapshotter: using overlayfs"
  time="2024-08-25T23:17:10Z" level=warning msg="using host network as the default"
  time="2024-08-25T23:17:11Z" level=info msg="found worker \"ngxgc47ehawj8q9jg4bpi8cpr\", labels=map[org.mobyproject.buildkit.worker.executor:oci org.mobyproject.buildkit.worker.hostname:8cc031c77965 org.mobyproject.buildkit.worker.network:host org.mobyproject.buildkit.worker.oci.process-mode:sandbox org.mobyproject.buildkit.worker.selinux.enabled:false org.mobyproject.buildkit.worker.snapshotter:overlayfs], platforms=[linux/amd64 linux/amd64/v2 linux/amd64/v3 linux/386]"
  time="2024-08-25T23:17:11Z" level=warning msg="skipping containerd worker, as \"/run/containerd/containerd.sock\" does not exist"
  time="2024-08-25T23:17:11Z" level=info msg="found 1 workers, default=\"ngxgc47ehawj8q9jg4bpi8cpr\""
  time="2024-08-25T23:17:11Z" level=warning msg="currently, only the default worker can be used."
  time="2024-08-25T23:17:11Z" level=info msg="running server on /run/buildkit/buildkitd.sock"
  ::endgroup::
::group::Removing builder
Removing builder
  /usr/bin/docker buildx rm builder-28b5b173-9f38-4a20-a162-268db18a288f
  builder-28b5b173-9f38-4a20-a162-268db18a288f removed
  ::endgroup::

As far as I understand, my files were temporarily stored on Docker Hub and then seem to have been deleted along with the builder. But isn’t this illogical, or is it just because I don’t fully understand how Docker Hub works that it seems illogical to me?

My only concern is whether there was any data leakage. Is there anything you can say about this, or do you have any articles you can recommend? Thanks for your support.

i see no indication of pushing images in your log. And as i mentioned, you can’t just push images anywhere on Docker Huib. Only to your own repository or where you are a contributor. But you have not set any image name in your compose file. If you did in the part you didn’t share, i would not now about it. Without setting the image tag, docker doesn’t know where to push the image. Just check the documentation of the compose push subcommand

You have to set the image name. If you don’t, although it is not mentioned in the documentation, compose will skip it. The command will be still successful. It has nothing to do with Docker Hub. Only about Docker and Docker Compose.

Again, pull can be successful even when it does not pull anything. There is nothing to pull as you have no image in the compose file

I would recommend learning Docker and Docker Compose basics before you use these tools in a pipeline. Then you would have all the error messages more easily. If everything works, then you can automate it.

2 Likes

I am very grateful for your mentorship and patience. As you mentioned, files without image names were skipped during the push or pull process, but they were still shown as successful. I apologize for my stubbornness :sweat_smile:. By joining a Docker Pro account, I created image names and mapped them to repositories, and when I did that, I saw that the process was completely successful, and the files were uploaded to my Docker Hub private repository. I’m thankful for the valuable information you provided and the time you took. I hope you have a great day!