Run docker image with docker-compose
you should build the image with this name: (registryName:RegistryPort)/imagename:version
$ docker build -t myRegistry.example.com:5000/myApp:latest .$ docker build -t myRegistry.example.com:5000/myDb:latest .
Now add these lines to the docker-compose file :
Myapp: image: myRegistry.example.com:5000/myApp:latest MyDb: image: myRegistry.example.com:5000/myDb:latest
And then push it :
$ docker push myRegistry.example.com:5000/myApp:latest$ docker push myRegistry.example.com:5000/myDb:latest
Your mate should now be able to pull it now
$ docker pull myRegistry.example.com:5000/myApp:latest$ docker pull myRegistry.example.com:5000/myDb:latest
Yes, You can use previously created image from repository
via docker compose
.
Example:
version: '2'services: app: image: farhad/my_app ports: - "80:80" networks: - testnetwork postgres: image: postgres:latest networks: - testnetworknetworks: testnetwork: external: true
Example Explaination:
I'm creating a container named app
from my repository and another container named postgres
via library postgres
image.
Please note you need to create an push your custom image to repository first.
I'm using user-defined
networks here, You need to create testnetwork
before docker-compose up
.