Is Docker compose available on unraid?


Recommended Posts

Hello after much trial and error with docker on Ubuntu and unraid I have found that the lancache pack by josh5 was the issue. Long story short it wasn’t allowing clients to access the cached data at full speed and it doesn’t segregate the data from different CDN providers.

 

the Docker ecosystem has had docker-compose for years, which the lancache team provide an example configuration for, that allows you to bring up all three containers with one CLI command. 

 

Am I able to get this to work on unraid directly without having to setup a vm ?

Link to comment
4 hours ago, Mrparkins said:

is docker compose meant to disappear on unraid or is it meant to persist after reboot ? 

 

Unraid unpacks fresh into RAM on every boot, so if you want something custom available, you must recreate it on boot. You can use either user scripts or the go file, depending on the timing you need.

  • Thanks 1
Link to comment

docker-compose is available in community applications > nerd pack

edit: it's not there anymore ??

anyway adding the below to /boot/config/go will make it permanent

 

 

COMPOSE_VERSION=$(curl -s https://api.github.com/repos/docker/compose/releases/latest | grep 'tag_name' | cut -d\" -f4)
curl -L https://github.com/docker/compose/releases/download/${COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` -o /us>
chmod +x /usr/local/bin/docker-compose


 

 

Edited by juan11perez
  • Like 1
Link to comment

Yeah, I'm finding I'm just outgrowing the unraid docker GUI.  I need to to create multi-image containers and such.  Trying to install something as 5 separate containers when unraid has little ability to offer any dependency mapping is a nightmare.  Especially during updates.  As far as I know, it can't work.  So docker compose solves it apparently.  But, for some reason it's been pulled from nerd pack, I'd certainly vote to have it back rather than have to use some bodgy script to keep it running.

Link to comment
  • 2 weeks later...

I have add a alias that launches docker-compose in a container. It has the benefit of being up-to-date without any modifications:

alias docker-compose='docker run --rm \
    -v /var/run/docker.sock:/var/run/docker.sock \
    -v "$PWD:$PWD" \
    -w="$PWD" \
    docker/compose:latest'

It has worked great so far for me.

  • Like 3
Link to comment
  • 1 month later...
On 5/7/2020 at 1:49 AM, Thx And Bye said:

I have add a alias that launches docker-compose in a container. It has the benefit of being up-to-date without any modifications:


alias docker-compose='docker run --rm \
    -v /var/run/docker.sock:/var/run/docker.sock \
    -v "$PWD:$PWD" \
    -w="$PWD" \
    docker/compose:latest'

It has worked great so far for me.

Interested in doing this, as it seems like its a relatively easy to maintain solution. Would you mind sharing your steps? I'm fairly new to some of the advanced features of Docker.

Link to comment
2 hours ago, theiam79 said:

Would you mind sharing your steps?

Eh, sure. Effectively you just have to execute the command from my other post. If you don't want to do that manually every time you open a ssh connection then you have to add it to this file:

/root/.bash_profile

 

To make it persistent across reboots (that's how I did it, not saying it's the most ideal way):

Edit /boot/config/go and add:  

# Customise bash
cat /boot/config/bash_extra.cfg >> /root/.bash_profile

Create the /boot/config/bash_extra.cfg (e.g. with nano) and add:

#docker-compose as container
alias docker-compose='docker run --rm \
    -v /var/run/docker.sock:/var/run/docker.sock \
    -v "$PWD:$PWD" \
    -w="$PWD" \
    docker/compose:latest'

And that's it. After a reboot that will add the command to the .bash_profile file meaning it'll automatically get executed one you open a shell.

Edited by Thx And Bye
  • Like 5
  • Thanks 1
Link to comment
On 4/23/2020 at 5:45 PM, juan11perez said:

docker-compose is available in community applications > nerd pack

edit: it's not there anymore ??

anyway adding the below to /boot/config/go will make it permanent

 

 


COMPOSE_VERSION=$(curl -s https://api.github.com/repos/docker/compose/releases/latest | grep 'tag_name' | cut -d\" -f4)
curl -L https://github.com/docker/compose/releases/download/${COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` -o /us>
chmod +x /usr/local/bin/docker-compose


 

 

 

It's not anymore.

You can now select some prerequisites from the NERDpack and then use pip3 to handle the install.

 

I've edited to my go (/boot/config/go) file:

 

# Since the NerdPack does not include this anymore we need to download docker-compose outselves.
# pip3, python3 and the setuptools are all provided by the nerdpack
# See: https://forums.unraid.net/index.php?/topic/35866-unRAID-6-NerdPack---CLI-tools-(iftop,-iotop,-screen,-kbd,-etc.&do=findComment&comment=838361)
pip3 install docker-compose

 

I must say that you curl solution looks clean and doesn't require setting up additional dependencies via the NERDpack in advance.

Bookmarked in case the pip3 solution might fail later on :)

 

EDIT: The curl solution seems to have been truncated @juan11perez. I wanted to use this in my Duplicati container but noticed that the second line is missing its end. The docker docs noted the full command:

COMPOSE_VERSION=$(curl -s https://api.github.com/repos/docker/compose/releases/latest | grep 'tag_name' | cut -d\" -f4)
curl -L https://github.com/docker/compose/releases/download/${COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose

You may want to edit your example in case anyone want to use.

Thanks!

Edited by S1dney
  • Like 3
Link to comment
  • 1 month later...

Hello,  as I am starting to play with docker and docker-compose, I want to ask please, how do I get docker-computer to use /mnt/user/appdata/  for named volumes. 

I make a nice yml to get joomla to run with mysql linked and this does work. 

  GNU nano 4.6                                          test.yml                                                    
version: '3.1'

services:
  joomla:
    image: joomla
    restart: always
    ports:
      - 8080:80
    environment:
      JOOMLA_DB_HOST: joomladb
      JOOMLA_DB_PASSWORD: xxxxxx
      JOOMLA_DB_NAME: Joomla
    volumes:
    - www-data:/var/www/html

  joomladb:
    image: mysql:5.6
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: xxxxxx
    volumes:
    - db-data:/var/lib/mysql

volumes:
  db-data:
  www-data:

The problem is that this mounts on the standard location and not to /mnt/user/appdata. 

 

root@Tower:/mnt/user/www/docker-compose# docker volume inspect docker-compose_db-data
[
    {
        "CreatedAt": "2020-07-17T20:56:32+01:00",
        "Driver": "local",
        "Labels": {
            "com.docker.compose.project": "docker-compose",
            "com.docker.compose.version": "1.25.5",
            "com.docker.compose.volume": "db-data"
        },
        "Mountpoint": "/var/lib/docker/volumes/docker-compose_db-data/_data",
        "Name": "docker-compose_db-data",
        "Options": null,
        "Scope": "local"
  

Is there a way to change "/var/lib/docker/volumes/docker-compose_db-data/_data". into "/mnt/user/data". as standard behaviour. 

Link to comment

So now I have it working the way I was looking to have it work:  Joomla and mySQL linked and working with docker-compose. 

 

version: '3.1'

services:
  joomla:
    image: joomla
    restart: always
    ports:
      - 8081:80
    environment:
      JOOMLA_DB_HOST: joomladb
      JOOMLA_DB_PASSWORD: PASSWORD
      JOOMLA_DB_NAME: Joomla
    volumes:
    - www-data:/var/www/html

  joomladb:
    image: mysql:5.6
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: PASSWORD
    volumes:
    - db-data:/var/lib/mysql

volumes:
    db-data:
      driver: local
      driver_opts:
        type: 'none'
        o: 'bind'
        device: '/mnt/user/MYWEBSITESHARE/DB'
    www-data:
      driver: local
      driver_opts:
        type: 'none'
        o: 'bind'
        device: '/mnt/user/MYWEBSITESHARE/www'

My choice is to have a website running Joomla in one directory with the DB next to it. I can easily back this up and so it's portable. 

 

- Joomla data in the www directory

- MySQL data in the DB directory 

and next to it I have a docker-compose directory to hold the yml file. 

 

With the named volume, I get to use the same mount for other data. 

 

Let me know what you think about this solution and if there would be an easier way towards this.

I do want to help others build some more custom yml and have fun and learn. 

 

-Thomas

Edited by Thomasg
Link to comment
  • 3 months later...

Hello everyone,

I'm new to UnRaid and looking for a little help on getting Seafile running on it. the manual says to use docker compose and they provide a .yml file. The directories appear to be mainly used for Ubuntu or Cent. Can you look at this compose file and tell me what locations would be better or if the ones they provide are good to use? On container updates if I use the locations they provide would they be wiped out? What location would I need to place those files so they are not cleared on container update?

 

Thank You!!!

 

version: '2.0'
services:
  db:
    image: mariadb:10.1
    container_name: seafile-mysql
    environment:
      - MYSQL_ROOT_PASSWORD=db_dev  # Requested, set the root's password of MySQL service.
      - MYSQL_LOG_CONSOLE=true
    volumes:
      - /opt/seafile-mysql/db:/var/lib/mysql  # Requested, specifies the path to MySQL data persistent store.
    networks:
      - seafile-net

  memcached:
    image: memcached:1.5.6
    container_name: seafile-memcached
    entrypoint: memcached -m 256
    networks:
      - seafile-net
          
  seafile:
    image: seafileltd/seafile-mc:latest
    container_name: seafile
    ports:
      - "80:80"
#     - "443:443"  # If https is enabled, cancel the comment.
    volumes:
      - /opt/seafile-data:/shared   # Requested, specifies the path to Seafile data persistent store.
    environment:
      - DB_HOST=db
      - DB_ROOT_PASSWD=db_dev  # Requested, the value shuold be root's password of MySQL service.
      - TIME_ZONE=Etc/UTC  # Optional, default is UTC. Should be uncomment and set to your local time zone.
      - SEAFILE_ADMIN_EMAIL=me@example.com # Specifies Seafile admin user, default is 'me@example.com'.
      - SEAFILE_ADMIN_PASSWORD=asecret     # Specifies Seafile admin password, default is 'asecret'.
      - SEAFILE_SERVER_LETSENCRYPT=false   # Whether to use https or not.
      - SEAFILE_SERVER_HOSTNAME=docs.seafile.com # Specifies your host name if https is enabled.
    depends_on:
      - db
      - memcached
    networks:
      - seafile-net

networks:
  seafile-net:

 

Edited by Smooth Beaver
Link to comment
  • 1 month later...
On 6/9/2020 at 9:08 AM, Thx And Bye said:

Eh, sure. Effectively you just have to execute the command from my other post. If you don't want to do that manually every time you open a ssh connection then you have to add it to this file:


/root/.bash_profile

 

To make it persistent across reboots (that's how I did it, not saying it's the most ideal way):

Edit /boot/config/go and add:  


# Customise bash
cat /boot/config/bash_extra.cfg >> /root/.bash_profile

Create the /boot/config/bash_extra.cfg (e.g. with nano) and add:


#docker-compose as container
alias docker-compose='docker run --rm \
    -v /var/run/docker.sock:/var/run/docker.sock \
    -v "$PWD:$PWD" \
    -w="$PWD" \
    docker/compose:latest'

And that's it. After a reboot that will add the command to the .bash_profile file meaning it'll automatically get executed one you open a shell.

Great work! Thank you very much.

Unfotuently, this gave me an error about invalid docker syntax. But after much trail and error, I've got it working.

 

You can show all alias with the same command (without any option parameter / or with -p)

You can also inspect an alias with the help of the tool "type":

type docker-compose

but the output was kind of strange with leading `ocker-compose...

 

tl;dr

I changed my alias name from "docker-compose" to "compose" and thats it.

 

EDIT:

ok, nvm. it's still broken...

the output of my .bash_profile file is: (I added both alias' docker-compose and compose for testing purposes..)

[...]
alias v="ls -lA"
#docker-compose as container
alias docker-compose='docker run --rm -v /var/run/docker.sock:/var/run/docker.sock -v "$PWD:$PWD" -w="$PWD" docker/compose:latest'
alias compose='docker run --rm -v /var/run/docker.sock:/var/run/docker.sock -v "$PWD:$PWD" -w="$PWD" docker/compose:latest'
alias ll='ls -lah'

seems good to me. but when I print the alias list:

'lias compose='docker run --rm -v /var/run/docker.sock:/var/run/docker.sock -v "$(PWD):$(PWD)" -w="$(PWD)" docker/compose:latest
'lias docker-compose='docker run --rm -v /var/run/docker.sock:/var/run/docker.sock -v "$(PWD):$(PWD)" -w="$(PWD)" docker/compose:latest
alias ll='ls -lah'
alias ls='/bin/ls $LS_OPTIONS'
alias mc='. /usr/share/mc/bin/mc-wrapper.sh'
alias user='su -ls /bin/bash'
alias v='ls -lA'

again these leading 'lias ....

and my type compose output:

'ompose is aliased to `docker run --rm -v /var/run/docker.sock:/var/run/docker.sock -v "$PWD:$PWD" -w="$PWD" docker/compose:latest

I don't get it... when I add the alias via hand, either in the .bash_profile file or directly in the cli, everthing works..

Here is the output from the compose command:

docker: invalid reference format.
See 'docker run --help'.

Do you guys have any ideas?

Edited by Timm
Link to comment
  • 2 weeks later...

Hey everyone, 
First of all wishing you a happy 2021!

In the next couple of weeks I am going to build my first unraid server (migrating from ubuntu). I have a question in regards to docker-compose in unraid.

Currently I have 29 docker containers running which are managed with docker-compose as it makes it very convenient.

Going forward, do you guys believe is worth migrating those to the docker template system of unraid or is it better to install docker-compose.
If I use the latter will I still be able to use the unraid docker management to do some managing or everything will be based on my docker-compose config file?

Thanks 

Link to comment
2 hours ago, Zentachi said:

Hey everyone, 
First of all wishing you a happy 2021!

In the next couple of weeks I am going to build my first unraid server (migrating from ubuntu). I have a question in regards to docker-compose in unraid.

Currently I have 29 docker containers running which are managed with docker-compose as it makes it very convenient.

Going forward, do you guys believe is worth migrating those to the docker template system of unraid or is it better to install docker-compose.
If I use the latter will I still be able to use the unraid docker management to do some managing or everything will be based on my docker-compose config file?

Thanks 

Best wishes to you too 👍

 

Whether to use docker-compose or Unraid’s own DockerMan, depends on what you want and/or need.

The DockerMan templates give you an easy option to redeploy containers from the GUI, you’ll also be notified when a docker container has an update available. I like Unraid’s tools so I default to these and create most containers from the GUI, however certain scenarios cannot be setup via DockerMan (at least not when I checked), like linking the network interfaces of containers together (so that all the container’s traffic flows through one of them).
 

Therefore I use docker-compose for those and also have some containers I’ve built myself that I want to setup with some dependencies. I update them via a bash script I wrote and redeploy them afterwards, as the GUI is not able to modify their properties (which answers your second question, containers deployed outside of the DockerMan GUI do not get a template and cannot be managed/updated, you can start and stop them tho).

 

My advise would be: stay with the Unraid default tooling unless you find a limitation which might make you want to deviate from them.

  • Like 1
Link to comment
On 1/3/2021 at 8:39 PM, S1dney said:

Best wishes to you too 👍

 

Whether to use docker-compose or Unraid’s own DockerMan, depends on what you want and/or need.

The DockerMan templates give you an easy option to redeploy containers from the GUI, you’ll also be notified when a docker container has an update available. I like Unraid’s tools so I default to these and create most containers from the GUI, however certain scenarios cannot be setup via DockerMan (at least not when I checked), like linking the network interfaces of containers together (so that all the container’s traffic flows through one of them).
 

Therefore I use docker-compose for those and also have some containers I’ve built myself that I want to setup with some dependencies. I update them via a bash script I wrote and redeploy them afterwards, as the GUI is not able to modify their properties (which answers your second question, containers deployed outside of the DockerMan GUI do not get a template and cannot be managed/updated, you can start and stop them tho).

 

My advise would be: stay with the Unraid default tooling unless you find a limitation which might make you want to deviate from them.

Many thanks for your detailed answer and advice.

I have watched a few videos (mainly from the great spaceinvaderone) about the DockerMan GUI and it does seem like a nice tool. Definitely I won't be able to transfer everything since I do have linked network interfaces for some. I don't know if its worth splitting my docker-compose file migrating some and leaving the rest. However, I might try it for a couple containers initially to check whether it will be convenient for me.

Which method you use to make your docker-compose permanent?
The below from a previous post or is there another one available nowdays?


 

  • Like 1
Link to comment
2 hours ago, Zentachi said:

Many thanks for your detailed answer and advice.

I have watched a few videos (mainly from the great spaceinvaderone) about the DockerMan GUI and it does seem like a nice tool. Definitely I won't be able to transfer everything since I do have linked network interfaces for some. I don't know if its worth splitting my docker-compose file migrating some and leaving the rest. However, I might try it for a couple containers initially to check whether it will be convenient for me.

Which method you use to make your docker-compose permanent?
The below from a previous post or is there another one available nowdays?


 

I've looked at my go file, I still have the pip3 way in place and it's working nice:

 

# Since the NerdPack does not include this anymore we need to download docker-compose outselves.
# pip3, python3 and the setuptools are all provided by the nerdpack
# See: https://forums.unraid.net/index.php?/topic/35866-unRAID-6-NerdPack---CLI-tools-(iftop,-iotop,-screen,-kbd,-etc.&do=findComment&comment=838361)
pip3 install docker-compose

The second way via curl also works well as I equipped my duplicati container with it.

You don't have to setup any dependencies that pip3 needs, so for simplicity reasons this may be more perferable.

 

Cheers!

  • Thanks 1
Link to comment
  • 1 month later...
On 12/22/2020 at 7:31 AM, Timm said:

Do you guys have any ideas?


I implemented Thx and Bye's method with a User Script that runs on  First Array Start Only.

 

#!/bin/bash
echo "
#docker-compose as container
alias docker-compose='docker run --rm -v /var/run/docker.sock:/var/run/docker.sock -v \"\$PWD:\$PWD\" -w=\"\$PWD\" docker/compose:latest'" >> /root/.bash_profile

 

Link to comment
On 5/6/2020 at 11:49 PM, Thx And Bye said:

I have add a alias that launches docker-compose in a container. It has the benefit of being up-to-date without any modifications:


alias docker-compose='docker run --rm \
    -v /var/run/docker.sock:/var/run/docker.sock \
    -v "$PWD:$PWD" \
    -w="$PWD" \
    docker/compose:latest'

It has worked great so far for me.

 

I am using this and it works, although as of unraid 6.9.0 RC2 it appears that the alias no longer works when called with the exec command in shell scripts.

Link to comment
14 hours ago, SimplifyAndAddCoffee said:

 

the alias no longer works when called with the exec command in shell scripts.

 

If you want to call from shell scrips, use the complete command, not the alias.

 

Like this:

docker run --rm -v /var/run/docker.sock:/var/run/docker.sock -v "$path:$path" -w="$path" docker/compose

$path has to be the directory where your compose file resides.

Edited by Thx And Bye
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.