Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker compose push to registry with Spring and mysql image

I'm new with docker-compose, i've created one that work good in my local default machine:

version: '3'

services:
  mysql-docker-container:
    image: mysql:latest
    environment:
      - MYSQL_ROOT_PASSWORD=*****
      - MYSQL_DATABASE=*****
      - MYSQL_USER=*****
      - MYSQL_PASSWORD=*****
    ports:
      - 3306:3306
    volumes:
      - /data/mysql
    restart: always
  myproject-server-container:
    image: myproject
    build:
      context: ./
      args:
        JAR_FILE: target/myproject-0.0.1-SNAPSHOT.jar
      dockerfile: Dockerfile
    depends_on:
      - mysql-docker-container
    ports:
      - 80:8080
    volumes:
      - /data/server
    restart: always

Now I need to push application with the mysql images to a remote registry. When I had just my project image without database container I simply did docker tag "imageId" "repo/myimageName" then docker push repo/myimageName.

Now how could I do the same with a docker-compose file?

like image 923
Frighi Avatar asked Oct 21 '25 15:10

Frighi


1 Answers

As you're using a public mysql image, you don't need to push that. You can just push your application image.

Should you want to also push the mysql image to your own private repository, you can do that by executing docker-compose push which will attempt to push all images.

Assuming you're hosting your own registry at example.com, you just need to set that as part of your image name in order to have the image go there instead of Docker hub.

version: '3'
services:
  service1:
    build: .
    image: example.com/yourimage  # goes to example.com registry

  service2:
    build: .
    image: youruser/yourimage  # goes to youruser DockerHub registry

See the documentation here for more options and examples

like image 170
Chris Turner Avatar answered Oct 23 '25 03:10

Chris Turner



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!