MAntunes
MAntunes

Reputation: 141

docker-compose creates directory instead of file

I'm trying to setup my home server (Ubuntu 18.04 LTS) using some docker containers and docker-compose. While trying to setup the "transmission-rss" I get the following error:

/usr/local/lib/ruby/2.6.0/psych.rb:577:in `initialize': Is a directory @ io_fillbuf - fd:5 /etc/transmission-rss.conf (Errno::EISDIR)

And when I went to check if the transmission-rss.conf file had been created a directory with the same name was created in its place.

I have to run the docker-compose up command using sudo so I don't know if this has anything to do with permissions.

Here is my current docker-compose.yml file:

version: '3'
services:
  portainer:
    container_name: portainer
    image: portainer/portainer
    volumes:
      - '/home/miguel/docker/portainer/data/:/data'
      - '/home/miguel/docker/portainer/socket/:/var/run/docker.sock'
    ports:
      - "9000:9000"
    restart: always
  transmission-rss:
    container_name: transmission-rss
    image: nning2/transmission-rss:latest
    volumes:
      - '/home/miguel/docker/transmission-rss/transmission-rss.conf/:/etc/transmission-rss.conf/'
    restart: unless-stopped

The portainer container starts fine.

Thank you very much, Miguel

Upvotes: 14

Views: 21342

Answers (3)

b01
b01

Reputation: 4384

At the time of writing (Docker v4.34.3) If the file does not exist on the Host machine running Docker, then a directory will be made.

You must make sure the file exist locally before running docker compose up. Or write a script to make sure the file exist then start your environment:

echo "" >> /home/miguel/docker/transmission-rss/transmission-rss.conf
docker compose up

NOTE: This should work on Linux/Mac/Windows Powershell.

You should also modify your compose.yml file to remove the trailing slashes.

# version: '3' this is no longer needed today.

services:
  portainer:
    container_name: portainer
    image: portainer/portainer
    volumes:
      - '/home/miguel/docker/portainer/data/:/data'
      - '/home/miguel/docker/portainer/socket/:/var/run/docker.sock'
    ports:
      - "9000:9000"
    restart: always

  transmission-rss:
    container_name: transmission-rss
    image: nning2/transmission-rss:latest
    volumes:
      - '/home/miguel/docker/transmission-rss/transmission-rss.conf:/etc/transmission-rss.conf'
    restart: unless-stopped

Upvotes: 0

mikey
mikey

Reputation: 1313

- '/home/miguel/docker/transmission-rss/transmission-rss.conf/:/etc/transmission-rss.conf/'

Please remove the trailing slashes (there are 2x!) and ensure transmission-rss.conf is a file, and not a dir on your host source.

To be slightly more comprehensive:

  1. Follow this to avoid having to use sudo with docker-compose: https://docs.docker.com/install/linux/linux-postinstall (this is not the cause of your issue, but it is annoying to have to preface every command with sudo, basically just need to add your user to the docker group).
  2. Update docker-compose.yml, remove the trailing slashes from source and target for transmission-rss.conf.
  3. Remove your existing volumes (docker volume ls + docker volume rm volume_name) after backing up your data, if needed.
  4. On your host (the machine you are running the docker-compose commands from), make sure the file exists, and is not a directory
  5. docker-compose down
  6. docker-compose build
  7. docker-compose up

Upvotes: 6

Ehsan Sarshar
Ehsan Sarshar

Reputation: 3211

make sure that files exist in both side (inside host machine and inside container).

if one of them not exist then docker create a directory instead of a file

Upvotes: 16

Related Questions