LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 05-02-2019, 11:03 AM   #1
funkytwig
Member
 
Registered: Jun 2016
Posts: 45

Rep: Reputation: Disabled
docker-conpose use .env to change service names


I am using nginx-proxy so I can host multiple WordPress docker containers on a server. Because of this, the service name for the DB (MariaDB) has to be different for each of the WordPress docker-compose.yml files (there is one for each site). I am using .env to set variables so I can use the same docker-compose.yml (so I can easily change them all, i.e. use symbolic links).

Problem is you cant use a variable for the service name. i.e. the following is not allowed:

version: '3'

services:

${DB_SERVICE}:
image: mariadb
volumes:
...

I did try COMPOSE_PROJECT_NAME which I thought appended to the service name but it does not (it only appends to the name of the created containers).

Any idea how I can do this?
Ben

Last edited by funkytwig; 05-02-2019 at 11:04 AM.
 
Old 06-02-2019, 09:22 AM   #2
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 13,486

Rep: Reputation: 4308Reputation: 4308Reputation: 4308Reputation: 4308Reputation: 4308Reputation: 4308Reputation: 4308Reputation: 4308Reputation: 4308Reputation: 4308Reputation: 4308
if this https://docs.docker.com/compose/environment-variables/ did not work for you: it looks like the only way is to generate them using a common template

Last edited by pan64; 06-02-2019 at 09:24 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Red Hat partners with Docker to create Linux/Docker software stack LXer Syndicated Linux News 0 03-12-2015 06:54 PM
LXer: Ubuntu LXD: Not a Docker replacement, a Docker enhancement LXer Syndicated Linux News 0 11-05-2014 09:40 PM
LXer: Docker Founder Explains What Docker is all About LXer Syndicated Linux News 0 08-21-2014 10:20 PM
RPM dependency failure: /usr/bin/env instead of /bin/env anoosh3000 Linux - Software 1 04-10-2009 06:34 AM
How to use $ENV in Perl to change enviroment variable 2007fld Programming 5 09-16-2007 08:49 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 02:42 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration