Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: inline file #3538

Closed
pierreozoux opened this issue Jun 1, 2016 · 17 comments
Closed

Feature: inline file #3538

pierreozoux opened this issue Jun 1, 2016 · 17 comments

Comments

@pierreozoux
Copy link

pierreozoux commented Jun 1, 2016

I create a lot of compose file that I hope are useful for the community.
I'd like to find a way for docker to officially ship these compose files.

There is one issue that IMHO is blocking us of doing so, is the ability to ship a file in docker-compose.
Indeed, what distinguish a piwik from an ownCloud from a WordPress compose file is only the nginx configuration.

There are 3 way that I know to ship this configuration:

The first option: a file on the host:

  volumes:
    - ./nginx.conf:/etc/nginx/nginx.conf:ro

The second option: the current inline way:

web:
  image: nginx
  volumes:
    - ./data:/var/www/html
  command: |
    bash -c 'bash -s <<EOF
      cat > /etc/nginx/nginx.conf <<EON
        daemon off;
        user www-data;
        events {
          worker_connections 768;
        }
        http {
          gzip on;
          gzip_disable "msie6";
          include /etc/nginx/mime.types;
          server {
            listen 80;
            root /var/www/html;
            index index.html;
          }
        }
    EON
    nginx
    EOF'

A bit dirty

The 3rd way: inline file

web:
  image: nginx
  volumes:
    - ./data:/var/www/html
  files:
    -   owner: root:root
        path: /etc/nginx/nginx.conf
        permissions: '0644'
        content: |
         user www-data;
          events {
            worker_connections 768;
          }
          http {
            gzip on;
            gzip_disable "msie6";
            include /etc/nginx/mime.types;
            server {
              listen 80;
              root /var/www/html;
              index index.html;
            }
          }

And so, I'm sure you see the value to have a proper way to add inline file.

The syntax could be similar to what cloudinit does.

With this, it would become easier to ship one compose file with everything included to get started an app!

@pierreozoux pierreozoux changed the title Feature: mount inline file Feature: inline file Jun 1, 2016
@bweston92
Copy link

bweston92 commented Dec 29, 2017

Would also help not over-engineering something. I have to use Docker configs for snippets of configuration when really it would be easier/portable in a single YAML file.

So for configs you could have something as follows:

version: '3.3'
services:
  postgresql:
    image: postgresql
    configs:
      - target: /postrgresql_config
        uid: '103'
        gid: '103'
        mode: 0440
        content: |
          myconfig: $(YOU)
          value: $(CAN) 
          other: $(TEMPLATIZE)

@Fridus
Copy link

Fridus commented Dec 19, 2018

@shin- Hi, any solution ?

@shin-
Copy link

shin- commented Dec 19, 2018

@Fridus Check out https://github.com/docker/app !

@ijc
Copy link

ijc commented Mar 29, 2019

Issue grooming: I think I agree with @shin- that this sounds more like a docker-app thing.

@adams-family
Copy link

+1

I'd like that, too!

@brunocascio
Copy link

Me too here :(

@MrBuddyCasino
Copy link

Inline files would also make it much easier to run docker compose on a remote host. Since docker app isn't a thing anymore, maybe reconsider closing this issue?

@wauwau0977
Copy link

Would like that too... k8s offers that as well, would like to see it in docker compose.

@dmckernanacv
Copy link

Bumping this, hard to believe it's not a thing, would be extremely useful.

@ezk84
Copy link

ezk84 commented Jun 10, 2022

+1. This would be useful.

@Mimikoo
Copy link

Mimikoo commented Mar 9, 2023

Any info on this?

@srstsavage
Copy link

srstsavage commented Jul 12, 2023

compose-spec/compose-spec#346

Please upvote if you'd like to see this implemented

@bergkvist
Copy link

This is available in Docker Compose version 2.23.1 now.

name: config-inline
services:
  service:
    image: ubuntu
    entrypoint: cat
    command: /path/to/config.txt
    configs:
      - source: config.txt
        target: /path/to/config.txt
configs:
  config.txt:
    content: |
      strawberry fields forever

Output:

$ docker-compose up
[+] Building 0.0s (0/0)                                                                   docker:default
[+] Running 2/0
 ✔ Network config-inline_default      Created                                                       0.0s 
 ✔ Container config-inline-service-1  Created                                                       0.0s 
Attaching to service-1
service-1  | strawberry fields forever
service-1 exited with code 0

@srstsavage
Copy link

This is great, and will make many deployments much simpler and cleaner. Thank you @ndeloof!

@sergioisidoro
Copy link

This is super great! I've been waiting for this for so long :D I've updated compose and works great.

However the I was a bit disappointed to discover that the spec does not yet seem to be available on swarm deploy, on engine 25.0.1. compose-spec/compose-spec#346 (comment)

@glours
Copy link
Contributor

glours commented Jan 29, 2024

Hello @sergioisidoro
Swarm isn't supported by Docker anymore but by Mirantis, maybe you could open an issue into the moby/moby project

@sergioisidoro
Copy link

Thanks @glours , I opened a issue in a sort of hail Mary :) from what I see from Mirantis' website, their focus seems to be mainly on Kubernetes, with no mention of swarm as a solution. I'm afraid this is going towards a dead end.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests