Kermit
Kermit

Reputation: 5992

Docker - can I provide a docker-compose.yml for DockerHub?

Rather than communicating the mess below to my users... is there a way I can somehow pair a docker-compose.yml file with my DockerHub image so that it automagically runs?

I would swap out the <VALUES> with arguments passed to up.


Create a file named docker-compose.yml and open it with a text editor (nano or SublimeText).

$ touch docker-compose.yml
$ nano docker-compose.yml

Paste the text below into that file. Be sure to swap in your path from earlier into the volumes key.

#docker-compose.yml
version: "3"
services:
  jupyter:
    image: "hashrocketsyntax/gorpyter:notebook"
    ports:
      - "8888:8888"
    volumes:
      - <PATH_TO_YOUR_NEW_FOLDER>:/home/jovyan
    environment:
      - JUPYTER_ENABLE_LAB=yes
      - R_HOME=/opt/conda/lib/R

Make sure you are in the same directory as the .yml file and run it like so.

$ docker-compose up

Upvotes: 0

Views: 150

Answers (2)

BMitch
BMitch

Reputation: 263617

This is the use case for Docker App. This is now shipping with docker 19.03 as a CLI plugin (though you may need to enable experimental CLI mode to use it there). You create a Docker App package that includes your compose file, parameters you want to allow users to modify, and the images used by your compose file. That gets bundled and pushed to your registry (often Docker Hub) as a special type of image. And users can then pull, configure, and deploy your app with a similar set of commands.

One word of caution, Docker App is still under active development at the time of this answer, and not yet at a 1.0 release, which means the behavior and CLI syntax may change. Because of this, most are still checking the compose file into github and distributing it from there.

For learning Docker App, there is a workshop created by Michael Irwin that you can try out.


Enabling experimental CLI mode involves a flag in the $HOME/.docker/config.json file. If your file is empty, the full file would look like:

{
  "experimental": "enabled"
}

If you already have entries in this file from registry logins, then add the experimental line near the end, remembering the comma separator from the previous section.

Upvotes: 1

DazWilkin
DazWilkin

Reputation: 40081

To my knowledge, no there isn't. It's a good question. I suspect the reason this does not exist is that docker-compose.yaml files tend (!) to not be machine|environment-independent.

It's not the answer to your question but an alternative approach solution that is widely used to solve this problem would be to define the equivalent orchestration using Kubernetes configs.

Kubernetes configs are necessarily cross-platform and would also provide you more (IMO) expressive syntax. The de facto deployment tool of Kubernetes applications is called Helm and Helm essentially auto-generates Kubernetes configuration files and applies these to a designated cluster.

Upvotes: 0

Related Questions