1
Step 3/10 : RUN mkdir -p /etc/nginx/{sites-available,sites-enabled}
Step 4/10 : COPY nginx.conf /etc/nginx/
Step 5/10 : COPY sites-available/*.conf /etc/nginx/sites-available/
Step 6/10 : RUN ln -s /etc/nginx/sites-available/* /etc/nginx/sites-enabled/
 ---> Running in a2f39a3fd6b3
ln: /etc/nginx/sites-enabled/: No such file or directory
ln: /etc/nginx/sites-enabled/: No such file or directory
ln: /etc/nginx/sites-enabled/: No such file or directory
ln: /etc/nginx/sites-enabled/: No such file or directory
ln: /etc/nginx/sites-enabled/: No such file or directory
ln: /etc/nginx/sites-enabled/: No such file or directory
ln: /etc/nginx/sites-enabled/: No such file or directory
ln: /etc/nginx/sites-enabled/: No such file or directory
The command '/bin/sh -c ln -s /etc/nginx/sites-available/* /etc/nginx/sites-enabled/*' returned a non-zero code: 1

Any clue why this isn't working? ^^ I tried all these commands outside of a docker container and it seemed to work

JordanPlayz158
  • 81
  • 1
  • 11
  • 1
    Is there any reason for first copying them to `sites-available` and then linking them? An alternative would be to copy the files to the `sites-enabled` directory directly – MaartenDev Jan 26 '20 at 18:07
  • Yeah, I'm dumb I could just copy them to sites-enabled, I'm just used to copying them to sites-available and linking them, Thanks for all the help :D – JordanPlayz158 Jan 26 '20 at 18:26
  • Yea same, in this case it isn't needed and can be simplified by copying it directly. I added the comment as answer so others can find it. Can you mark it as answer so others can find it? – MaartenDev Jan 26 '20 at 18:28
  • 1
    Done! Again thanks for the help, it is much appreciated! – JordanPlayz158 Jan 26 '20 at 18:33

2 Answers2

1

This could be solved by copying the files directly to the sites-enabled directory with the following statement:

COPY sites-available/*.conf /etc/nginx/sites-enabled/
MaartenDev
  • 5,631
  • 5
  • 21
  • 33
1

Your step 3 includes a bashism:

mkdir -p /etc/nginx/{sites-available,sites-enabled}

With the default /bin/sh, this will create a single directory rather than the two directories you wanted:

$ docker run -it --rm nginx /bin/sh

# ls -al /etc/nginx
total 48
drwxr-xr-x 3 root root 4096 Dec 28 15:20 .
drwxr-xr-x 1 root root 4096 Jan 26 19:46 ..
drwxr-xr-x 2 root root 4096 Dec 28 15:20 conf.d
-rw-r--r-- 1 root root 1007 Nov 19 12:50 fastcgi_params
-rw-r--r-- 1 root root 2837 Nov 19 12:50 koi-utf
-rw-r--r-- 1 root root 2223 Nov 19 12:50 koi-win
-rw-r--r-- 1 root root 5231 Nov 19 12:50 mime.types
lrwxrwxrwx 1 root root   22 Nov 19 12:50 modules -> /usr/lib/nginx/modules
-rw-r--r-- 1 root root  643 Nov 19 12:50 nginx.conf
-rw-r--r-- 1 root root  636 Nov 19 12:50 scgi_params
-rw-r--r-- 1 root root  664 Nov 19 12:50 uwsgi_params
-rw-r--r-- 1 root root 3610 Nov 19 12:50 win-utf

# mkdir -p /etc/nginx/{sites-available,sites-enabled}

# ls -al /etc/nginx
total 56
drwxr-xr-x 1 root root 4096 Jan 26 19:47 .
drwxr-xr-x 1 root root 4096 Jan 26 19:46 ..
drwxr-xr-x 2 root root 4096 Dec 28 15:20 conf.d
-rw-r--r-- 1 root root 1007 Nov 19 12:50 fastcgi_params
-rw-r--r-- 1 root root 2837 Nov 19 12:50 koi-utf
-rw-r--r-- 1 root root 2223 Nov 19 12:50 koi-win
-rw-r--r-- 1 root root 5231 Nov 19 12:50 mime.types
lrwxrwxrwx 1 root root   22 Nov 19 12:50 modules -> /usr/lib/nginx/modules
-rw-r--r-- 1 root root  643 Nov 19 12:50 nginx.conf
-rw-r--r-- 1 root root  636 Nov 19 12:50 scgi_params
-rw-r--r-- 1 root root  664 Nov 19 12:50 uwsgi_params
-rw-r--r-- 1 root root 3610 Nov 19 12:50 win-utf
drwxr-xr-x 2 root root 4096 Jan 26 19:47 {sites-available,sites-enabled}

For /bin/sh, you need to list them individually:

# mkdir -p /etc/nginx/sites-available /etc/nginx/sites-enabled

# ls -al /etc/nginx
total 64
drwxr-xr-x 1 root root 4096 Jan 26 19:49 .
drwxr-xr-x 1 root root 4096 Jan 26 19:46 ..
drwxr-xr-x 2 root root 4096 Dec 28 15:20 conf.d
-rw-r--r-- 1 root root 1007 Nov 19 12:50 fastcgi_params
-rw-r--r-- 1 root root 2837 Nov 19 12:50 koi-utf
-rw-r--r-- 1 root root 2223 Nov 19 12:50 koi-win
-rw-r--r-- 1 root root 5231 Nov 19 12:50 mime.types
lrwxrwxrwx 1 root root   22 Nov 19 12:50 modules -> /usr/lib/nginx/modules
-rw-r--r-- 1 root root  643 Nov 19 12:50 nginx.conf
-rw-r--r-- 1 root root  636 Nov 19 12:50 scgi_params
drwxr-xr-x 2 root root 4096 Jan 26 19:49 sites-available
drwxr-xr-x 2 root root 4096 Jan 26 19:49 sites-enabled
-rw-r--r-- 1 root root  664 Nov 19 12:50 uwsgi_params
-rw-r--r-- 1 root root 3610 Nov 19 12:50 win-utf
drwxr-xr-x 2 root root 4096 Jan 26 19:47 {sites-available,sites-enabled}
BMitch
  • 231,797
  • 42
  • 475
  • 450