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
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/
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}
Related
was trying to make a quick dbt container:
docker pull xemuliam/dbt
docker run -d --name dbt \
-p 8085:8085 \
-v /home/mypath/app:/usr/app \
xemuliam/dbt:latest
that didn't work, so i tried to inspect and saw the binding was rprivate, so i changed it to:
docker run -d --name dbt \
-p 8085:8085 \
-v /home/mypath/app:/usr/app,rshared:rshared \
xemuliam/dbt:latest
the issue is that /home/mypath/app ends up being empty, and if i go inside the container it has in the working directory of /usr/app:
drwxr-xr-x 15 root root 4096 Apr 29 12:24 .
drwxr-xr-x 1 root root 4096 Jun 21 20:14 ..
-rw-rw-r-- 1 root root 4895 Apr 28 16:54 ARCHITECTURE.md
-rwxrwxr-x 1 root root 16732 Apr 28 16:54 CHANGELOG.md
-rw-rw-r-- 1 root root 18081 Apr 28 16:54 CONTRIBUTING.md
-rw-rw-r-- 1 root root 2239 Apr 28 16:54 Dockerfile.test
-rw-rw-r-- 1 root root 11344 Apr 28 16:54 License.md
-rw-rw-r-- 1 root root 3271 Apr 28 16:54 Makefile
-rw-rw-r-- 1 root root 2365 Apr 28 16:54 README.md
drwxrwxr-x 5 root root 4096 Apr 28 16:54 core
drwxrwxr-x 4 root root 4096 Apr 29 12:23 dbt-core-1.1.0
-rw-rw-r-- 1 root root 205 Apr 28 16:54 dev-requirements.txt
drwxrwxr-x 2 root root 4096 Apr 28 16:54 docker
-rw-rw-r-- 1 root root 777 Apr 28 16:54 docker-compose.yml
drwxrwxr-x 3 root root 4096 Apr 28 16:54 docs
-rw-rw-r-- 1 root root 51 Apr 28 16:54 editable-requirements.txt
drwxrwxr-x 2 root root 4096 Apr 28 16:54 etc
drwxrwxr-x 3 root root 4096 Apr 28 16:54 events
-rw-rw-r-- 1 root root 65 Apr 28 16:54 mypy.ini
drwxrwxr-x 8 root root 4096 Apr 28 16:54 performance
drwxrwxr-x 6 root root 4096 Apr 28 16:54 plugins
-rw-r--r-- 1 root root 95 Apr 29 12:23 plugins.txt
-rw-rw-r-- 1 root root 242 Apr 28 16:54 pytest.ini
-rw-rw-r-- 1 root root 26 Apr 28 16:54 requirements.txt
drwxrwxr-x 2 root root 4096 Apr 28 16:54 scripts
drwxrwxr-x 5 root root 4096 Apr 28 16:54 test
drwxrwxr-x 7 root root 4096 Apr 28 16:54 tests
drwxrwxr-x 10 root root 4096 Apr 28 16:54 third-party-stubs
-rw-rw-r-- 1 root root 798 Apr 28 16:54 tox.ini
drwxr-xr-x 2 root root 4096 Apr 29 12:24 wheels
in my postgres db i am able to do a volume like this and it works:
-v /home/mypath/data:/var/lib/postgresql/data
i would like to access that stuff on the host so i can play around with editing it.
this is probably the worst way to get this done, so i would appreciate a better answer - but my solution:
step 1: pull image
$ podman pull xemuliam/dbt
step 2: create a container through cli instead of dockerfile
$ podman run -d --name db_dbt \
-p 8085:8085 \
-v /home/myusr/dbt_test/_official:/home/dbt_test/_official \
xemuliam/dbt:latest
step 3: copy files from /usr/app to /home/dbt_test/_official
$ cp -R /usr/app/* /home/dbt_test/_official
exit
$ podman stop db_dbt && podman rm db_dbt
step 4: copy files on the host
$ mkdir /home/myusr/dbt_test/app1
$ cp -R /home/myusr/dbt_test/_official/* /home/myusr/dbt_test/app1/
step 5: create a new volume
$ podman run -d --name db_dbt \
-p 8085:8085 \
-v /home/myusr/dbt_test/app1/:/usr/app/ \
xemuliam/dbt:latest
i really dont like this roundabout way, but now i am able to edit from the host and see what the container does.
I have a docker image built from an F# project that uses Paket. At run time the image fails with:
It was not possible to find any compatible framework version The
specified framework 'Microsoft.AspNetCore.App', version '2.2.7' was
not found.
My dockerfile looks like this:
# Two stage build because Paket means project files reference external files
# via <Import Project="..\.paket\Paket.Restore.targets" />
# https://github.com/fsprojects/Paket/issues/3006#issuecomment-359750323
FROM microsoft/dotnet:2.2-sdk-alpine AS build
RUN apk update \
&& apk add --no-cache bash
WORKDIR /app
# copy fsproj and restore as distinct layers
COPY MyCompany.WebApi/MyCompany.WebApi.fsproj ./MyCompany.WebApi/
COPY NuGet.config ./
RUN dotnet restore MyCompany.WebApi/MyCompany.WebApi.fsproj --configfile NuGet.config
# copy everything else and build
COPY . ./
RUN dotnet publish MyCompany.WebApi/MyCompany.WebApi.fsproj -c Release -o out
# build runtime image
FROM microsoft/dotnet:2.2-sdk-alpine AS final
RUN apk update \
&& apk add --no-cache bash
WORKDIR /app
COPY --from=build /app/MyCompany.WebApi/out ./
ENTRYPOINT ["dotnet", "MyCompany.WebApi.dll"]
Same problem occurs if I use 2.2-runtime-alpine as the basis for final.
My packet.lock includes these lines:
// https://github.com/fsharp/FAKE/issues/2193:
version 5.216.0
...
source https://api.nuget.org/v3/index.json
...
nuget Microsoft.AspNetCore.App
...
I notice that my generated paket.dependencies specifies a particular version of Microsoft.AspNetCore.App:
Microsoft.AspNetCore.App (2.2.7)
Microsoft.AspNet.WebApi.Client (>= 5.2.6 < 5.3) - restriction: >= netcoreapp2.2
Microsoft.AspNetCore (>= 2.2 < 2.3) - restriction: >= netcoreapp2.2
Microsoft.AspNetCore.Antiforgery (>= 2.2 < 2.3) - restriction: >= netcoreapp2.2
...although it looks like we are discouraged from specifying versions:
https://learn.microsoft.com/en-us/aspnet/core/fundamentals/metapackage-app?view=aspnetcore-2.2
So my question is: is it possible to come up with a combination of Docker, Paket, F# and AspNetCore that works together?
Edit: paket.dependencies -> packet.lock
Edit 2: Here's a listing of the entry point's directory and below:
.:
total 18668
-rwxr--r-- 1 root root 190976 Aug 29 13:18 Dapper.dll
-rwxr--r-- 1 root root 2850168 Aug 2 19:03 FSharp.Core.dll
-rwxr--r-- 1 root root 243200 Apr 16 08:00 Fable.Core.dll
-rwxr--r-- 1 root root 342528 Feb 10 2019 Giraffe.dll
...lots more DLLs from Nuget dependencies
... some DLLs from our internal dependencies
-rw-r--r-- 1 root root 100670 Sep 12 13:23 MyCompany.WebApi.deps.json
-rwxr-xr-x 1 root root 61440 Sep 12 13:23 MyCompany.WebApi.dll
-rw-r--r-- 1 root root 10608 Sep 12 13:23 MyCompany.WebApi.pdb
-rw-r--r-- 1 root root 149 Sep 12 13:23 MyCompany.WebApi.runtimeconfig.json
-rwxr--r-- 1 root root 178824 Nov 28 2018 System.Net.Http.Formatting.dll
-rwxr--r-- 1 root root 23088 Sep 18 2018 System.Runtime.CompilerServices.Unsafe.dll
-rwxr--r-- 1 root root 29744 Feb 15 2019 System.Security.Cryptography.OpenSsl.dll
-rwxr--r-- 1 root root 189168 Nov 29 2018 System.Security.Cryptography.Pkcs.dll
-rwxr--r-- 1 root root 29760 Jul 19 2018 System.ServiceModel.Primitives.dll
-rwxr--r-- 1 root root 30784 Jul 19 2018 System.ServiceModel.dll
-rwxr--r-- 1 root root 759024 Nov 29 2018 System.Text.Encoding.CodePages.dll
-rwxr--r-- 1 root root 91136 Sep 16 2018 TaskBuilder.fs.dll
drwxr-xr-x 2 root root 4096 Sep 12 13:23 cs
drwxr-xr-x 2 root root 4096 Sep 12 13:23 de
drwxr-xr-x 2 root root 4096 Sep 12 13:23 es
drwxr-xr-x 2 root root 4096 Sep 12 13:23 fr
drwxr-xr-x 2 root root 4096 Sep 12 13:23 it
drwxr-xr-x 2 root root 4096 Sep 12 13:23 ja
drwxr-xr-x 2 root root 4096 Sep 12 13:23 ko
drwxr-xr-x 2 root root 4096 Sep 12 13:23 pl
-rwxr--r-- 1 root root 277504 Aug 30 2018 protobuf-net.dll
drwxr-xr-x 2 root root 4096 Sep 12 13:23 pt-BR
drwxr-xr-x 2 root root 4096 Sep 12 13:23 ru
drwxr-xr-x 4 root root 4096 Sep 12 13:23 runtimes
drwxr-xr-x 2 root root 4096 Sep 12 13:23 tr
drwxr-xr-x 2 root root 4096 Sep 12 13:23 zh-Hans
drwxr-xr-x 2 root root 4096 Sep 12 13:23 zh-Hant
./cs:
total 376
-rwxr--r-- 1 root root 33144 Aug 2 19:03 FSharp.Core.resources.dll
-rwxr--r-- 1 root root 308088 Aug 8 16:19 Microsoft.CodeAnalysis.CSharp.resources.dll
-rwxr--r-- 1 root root 34896 Aug 8 16:18 Microsoft.CodeAnalysis.resources.dll
./de:
total 392
-rwxr--r-- 1 root root 34168 Aug 2 19:03 FSharp.Core.resources.dll
-rwxr--r-- 1 root root 327544 Aug 8 16:19 Microsoft.CodeAnalysis.CSharp.resources.dll
-rwxr--r-- 1 root root 36216 Aug 8 16:18 Microsoft.CodeAnalysis.resources.dll
./es:
total 388
-rwxr--r-- 1 root root 33360 Aug 2 19:03 FSharp.Core.resources.dll
-rwxr--r-- 1 root root 321104 Aug 8 16:19 Microsoft.CodeAnalysis.CSharp.resources.dll
-rwxr--r-- 1 root root 35920 Aug 8 16:18 Microsoft.CodeAnalysis.resources.dll
./fr:
total 392
-rwxr--r-- 1 root root 33656 Aug 2 19:03 FSharp.Core.resources.dll
-rwxr--r-- 1 root root 327544 Aug 8 16:19 Microsoft.CodeAnalysis.CSharp.resources.dll
-rwxr--r-- 1 root root 36432 Aug 8 16:18 Microsoft.CodeAnalysis.resources.dll
./it:
total 392
-rwxr--r-- 1 root root 33144 Aug 2 19:03 FSharp.Core.resources.dll
-rwxr--r-- 1 root root 325496 Aug 8 16:19 Microsoft.CodeAnalysis.CSharp.resources.dll
-rwxr--r-- 1 root root 36216 Aug 8 16:18 Microsoft.CodeAnalysis.resources.dll
./ja:
total 428
-rwxr--r-- 1 root root 35704 Aug 2 19:03 FSharp.Core.resources.dll
-rwxr--r-- 1 root root 358776 Aug 8 16:19 Microsoft.CodeAnalysis.CSharp.resources.dll
-rwxr--r-- 1 root root 38264 Aug 8 16:18 Microsoft.CodeAnalysis.resources.dll
./ko:
total 396
-rwxr--r-- 1 root root 34680 Aug 2 19:03 FSharp.Core.resources.dll
-rwxr--r-- 1 root root 331336 Aug 8 16:19 Microsoft.CodeAnalysis.CSharp.resources.dll
-rwxr--r-- 1 root root 36728 Aug 8 16:18 Microsoft.CodeAnalysis.resources.dll
./pl:
total 396
-rwxr--r-- 1 root root 34168 Aug 2 19:03 FSharp.Core.resources.dll
-rwxr--r-- 1 root root 331128 Aug 8 16:19 Microsoft.CodeAnalysis.CSharp.resources.dll
-rwxr--r-- 1 root root 36216 Aug 8 16:18 Microsoft.CodeAnalysis.resources.dll
./pt-BR:
total 380
-rwxr--r-- 1 root root 32632 Aug 2 19:03 FSharp.Core.resources.dll
-rwxr--r-- 1 root root 316280 Aug 8 16:19 Microsoft.CodeAnalysis.CSharp.resources.dll
-rwxr--r-- 1 root root 35704 Aug 8 16:18 Microsoft.CodeAnalysis.resources.dll
./ru:
total 508
-rwxr--r-- 1 root root 39800 Aug 2 19:03 FSharp.Core.resources.dll
-rwxr--r-- 1 root root 430968 Aug 8 16:19 Microsoft.CodeAnalysis.CSharp.resources.dll
-rwxr--r-- 1 root root 42360 Aug 8 16:18 Microsoft.CodeAnalysis.resources.dll
./runtimes:
total 8
drwxr-xr-x 3 root root 4096 Sep 12 13:23 unix
drwxr-xr-x 3 root root 4096 Sep 12 13:23 win
./runtimes/unix:
total 4
drwxr-xr-x 4 root root 4096 Sep 12 13:23 lib
./runtimes/unix/lib:
total 8
drwxr-xr-x 2 root root 4096 Sep 12 13:23 netcoreapp2.1
drwxr-xr-x 2 root root 4096 Sep 12 13:23 netstandard2.0
./runtimes/unix/lib/netcoreapp2.1:
total 88
-rwxr--r-- 1 root root 86280 Feb 15 2019 System.Security.Cryptography.OpenSsl.dll
./runtimes/unix/lib/netstandard2.0:
total 1848
-rwxr--r-- 1 root root 1889344 Jul 19 2018 System.Private.ServiceModel.dll
./runtimes/win:
total 4
drwxr-xr-x 5 root root 4096 Sep 12 13:23 lib
./runtimes/win/lib:
total 12
drwxr-xr-x 2 root root 4096 Sep 12 13:23 netcoreapp2.0
drwxr-xr-x 2 root root 4096 Sep 12 13:23 netcoreapp2.1
drwxr-xr-x 2 root root 4096 Sep 12 13:23 netstandard2.0
./runtimes/win/lib/netcoreapp2.0:
total 744
-rwxr--r-- 1 root root 761392 Nov 29 2018 System.Text.Encoding.CodePages.dll
./runtimes/win/lib/netcoreapp2.1:
total 212
-rwxr--r-- 1 root root 214064 Nov 29 2018 System.Security.Cryptography.Pkcs.dll
./runtimes/win/lib/netstandard2.0:
total 1848
-rwxr--r-- 1 root root 1889344 Jul 19 2018 System.Private.ServiceModel.dll
./tr:
total 376
-rwxr--r-- 1 root root 32632 Aug 2 19:03 FSharp.Core.resources.dll
-rwxr--r-- 1 root root 312184 Aug 8 16:19 Microsoft.CodeAnalysis.CSharp.resources.dll
-rwxr--r-- 1 root root 35192 Aug 8 16:18 Microsoft.CodeAnalysis.resources.dll
./zh-Hans:
total 344
-rwxr--r-- 1 root root 31096 Aug 2 19:03 FSharp.Core.resources.dll
-rwxr--r-- 1 root root 278904 Aug 8 16:19 Microsoft.CodeAnalysis.CSharp.resources.dll
-rwxr--r-- 1 root root 33144 Aug 8 16:18 Microsoft.CodeAnalysis.resources.dll
./zh-Hant:
total 344
-rwxr--r-- 1 root root 30584 Aug 2 19:03 FSharp.Core.resources.dll
-rwxr--r-- 1 root root 280144 Aug 8 16:19 Microsoft.CodeAnalysis.CSharp.resources.dll
-rwxr--r-- 1 root root 33360 Aug 8 16:18 Microsoft.CodeAnalysis.resources.dll
I think I've fixed this. Changed the base image to one I found referenced in a Microsoft tutorial, and removed the apk update stage (as this returned a non-zero exit code with this new base image). So this is my dockerfile now.
FROM mcr.microsoft.com/dotnet/core/sdk:2.2 AS build
WORKDIR /app
# copy fsproj and restore as distinct layers
COPY MyCompany.WebApi/MyCompany.WebApi.fsproj ./MyCompany.WebApi/
COPY NuGet.config ./
RUN dotnet restore MyCompany.WebApi/MyCompany.WebApi.fsproj --configfile NuGet.config
# copy everything else and build
COPY . ./
RUN dotnet publish MyCompany.WebApi/MyCompany.WebApi.fsproj -c Release -o out
# build runtime image
FROM mcr.microsoft.com/dotnet/core/aspnet:2.2 AS final
WORKDIR /app
COPY --from=build /app/MyCompany.WebApi/out ./
ENTRYPOINT ["dotnet", "MyCompany.WebApi.dll"]
It starts up OK now, haven't yet tested the functionality!
I am far from a Docker or Linux expert, but I would hazard a guess that the Alpine image hasn't caught up with the latest dotnet releases. I would also guess that the image I create after this change is fatter than it needs to be, but I'll take 'fat and working' for now.
Dockerfile contents:
# Setup directory structure
RUN mkdir -p /dev/log/ \
&& touch /dev/log/placeholder.file \
&& ls -la /dev/
As you can see below, the /dev/log/ folder is conspicuously missing from the actual container after being visible in the docker build output. Where is it going? Is /dev/ considered a special folder?
docker build output:
Step 13/14 : RUN mkdir -p /dev/log/ && touch /dev/log/placeholder.file && ls -la /dev/
---> Running in ac5014b75a54
total 4
drwxr-xr-x 6 root root 360 Oct 17 15:04 .
drwxr-xr-x 1 root root 4096 Oct 17 15:04 ..
lrwxrwxrwx 1 root root 11 Oct 17 15:04 core -> /proc/kcore
lrwxrwxrwx 1 root root 13 Oct 17 15:04 fd -> /proc/self/fd
crw-rw-rw- 1 root root 1, 7 Oct 17 15:04 full
drwxr-xr-x 2 root root 60 Oct 17 15:04 log
drwxrwxrwt 2 root root 40 Oct 17 15:04 mqueue
crw-rw-rw- 1 root root 1, 3 Oct 17 15:04 null
lrwxrwxrwx 1 root root 8 Oct 17 15:04 ptmx -> pts/ptmx
drwxr-xr-x 2 root root 0 Oct 17 15:04 pts
crw-rw-rw- 1 root root 1, 8 Oct 17 15:04 random
drwxrwxrwt 2 root root 40 Oct 17 15:04 shm
lrwxrwxrwx 1 root root 15 Oct 17 15:04 stderr -> /proc/self/fd/2
lrwxrwxrwx 1 root root 15 Oct 17 15:04 stdin -> /proc/self/fd/0
lrwxrwxrwx 1 root root 15 Oct 17 15:04 stdout -> /proc/self/fd/1
crw-rw-rw- 1 root root 5, 0 Oct 17 15:04 tty
crw-rw-rw- 1 root root 1, 9 Oct 17 15:04 urandom
crw-rw-rw- 1 root root 1, 5 Oct 17 15:04 zero
---> 2bdcd739e2c7
Removing intermediate container ac5014b75a54
View from inside the container:
docker run -it --rm <container> /bin/bash
[root#moby dev]# ls -al
total 4
drwxr-xr-x 5 root root 360 Oct 17 15:19 .
drwxr-xr-x 1 root root 4096 Oct 17 15:19 ..
crw--w---- 1 root tty 136, 0 Oct 17 2017 console
lrwxrwxrwx 1 root root 11 Oct 17 15:19 core -> /proc/kcore
lrwxrwxrwx 1 root root 13 Oct 17 15:19 fd -> /proc/self/fd
crw-rw-rw- 1 root root 1, 7 Oct 17 15:19 full
drwxrwxrwt 2 root root 40 Oct 17 15:19 mqueue
crw-rw-rw- 1 root root 1, 3 Oct 17 15:19 null
lrwxrwxrwx 1 root root 8 Oct 17 15:19 ptmx -> pts/ptmx
drwxr-xr-x 2 root root 0 Oct 17 15:19 pts
crw-rw-rw- 1 root root 1, 8 Oct 17 15:19 random
drwxrwxrwt 2 root root 40 Oct 17 15:19 shm
lrwxrwxrwx 1 root root 15 Oct 17 15:19 stderr -> /proc/self/fd/2
lrwxrwxrwx 1 root root 15 Oct 17 15:19 stdin -> /proc/self/fd/0
lrwxrwxrwx 1 root root 15 Oct 17 15:19 stdout -> /proc/self/fd/1
crw-rw-rw- 1 root root 5, 0 Oct 17 15:19 tty
crw-rw-rw- 1 root root 1, 9 Oct 17 15:19 urandom
crw-rw-rw- 1 root root 1, 5 Oct 17 15:19 zero
Is /dev/ considered a special folder?
Short answer, yes. It is a special folder and you shouldn't store stuff there. What is happening is that /dev gets mounted at container runtime, which is overwriting your folder:
$ docker run ubuntu mount | grep "/dev"
tmpfs on /dev type tmpfs (rw,nosuid,size=65536k,mode=755)
You will need to choose another place to store files or create the folder at runtime so that it happens after the mount.
I'm having in Dockerfile:
ENV DATARATOR_HOME /usr/local/share/datarator
RUN mkdir -p $DATARATOR_HOME
COPY . $DATARATOR_HOME
and .dockerignore file:
/Gemfile.lock
/coverage
/spec
*.bundle
*.so
*.o
*.a
mkmf.log
*.swp
/.*
/tmp
/log
However, once showing files in the built container, I can see also those that are supposed to be ignored:
/usr/local/share/datarator # ls -lha
total 128
drwxr-xr-x 10 root root 4.0K Mar 29 21:01 .
drwxr-xr-x 4 root root 4.0K Mar 29 21:00 ..
drwxr-xr-x 2 root root 4.0K Mar 29 21:01 .bundle
-rw-rw-r-- 1 root root 24 Mar 29 20:37 .coveralls.yml
-rw-rw-r-- 1 root root 81 Mar 29 20:37 .dockerignore
drwxrwxr-x 8 root root 4.0K Mar 29 20:37 .git
-rw-rw-r-- 1 root root 85 Mar 29 20:37 .gitignore
-rw-rw-r-- 1 root root 1.2K Mar 29 20:37 .travis.yml
-rw-rw-r-- 1 root root 509 Mar 29 20:37 .vimrc
-rw-rw-r-- 1 root root 959 Mar 29 20:37 Dockerfile
-rw-rw-r-- 1 root root 94 Mar 29 20:37 Gemfile
-rw-r--r-- 1 root root 2.7K Mar 29 21:01 Gemfile.lock
-rw-rw-r-- 1 root root 343 Mar 29 20:37 Guardfile
-rw-rw-r-- 1 root root 1.0K Mar 29 20:37 LICENSE.txt
-rw-rw-r-- 1 root root 71 Mar 29 20:37 Procfile
-rw-rw-r-- 1 root root 14.8K Mar 29 20:37 README.md
-rw-rw-r-- 1 root root 198 Mar 29 20:37 Rakefile
drwxrwxr-x 2 root root 4.0K Mar 29 20:37 bin
drwxrwxr-x 2 root root 4.0K Mar 29 20:37 config
-rw-rw-r-- 1 root root 97 Mar 29 20:37 config.ru
-rw-r--r-- 1 root root 16.0K Mar 29 21:01 datarator-0.0.1.gem
-rw-rw-r-- 1 root root 1.7K Mar 29 20:37 datarator.gemspec
drwxrwxr-x 4 root root 4.0K Mar 29 20:37 lib
drwxrwxr-x 2 root root 4.0K Mar 29 20:37 log
drwxrwxr-x 3 root root 4.0K Mar 29 20:37 spec
drwxrwxr-x 2 root root 4.0K Mar 29 20:37 tmp
How can I achieve having all those mentioned in the .dockerignore file ignored?
The .dockerignore rules follow the filepath/#Match.
Try (for testing) Gemfile.lock instead of /Gemfile.lock.
And check that the eol (end of line) characters are unix-style, not Windows style in your .dockerignore file.
Apparently, (docker 1.10, March 2016) using rule starting with / like /xxx ( or /.*) is not well supported.
Here's the complete syntax for the .dockerignore:
pattern:
{ term }
term:
'*' matches any sequence of non-Separator characters
'?' matches any single non-Separator character
'[' [ '^' ] { character-range } ']'
character class (must be non-empty)
c matches character c (c != '*', '?', '\\', '[')
'\\' c matches character c
character-range:
c matches character c (c != '\\', '-', ']')
'\\' c matches character c
lo '-' hi matches character c for lo <= c <= hi
additions:
'**' matches any number of directories (including zero)
'!' lines starting with ! (exclamation mark) can be used to make exceptions to exclusions
'#' lines starting with this character are ignored: use it for comments
Therefore, some of your matches would be changed according to the above syntax:
/Gemfile.lock --> */Gemfile.lock or **/Gemfile.lock or *.lock
/spec --> */spec or **/spec
/tmp --> in the same way
/log --> in the same way
Here are two articles to explain more:
Reference
Reference
I have a docker image built from ubuntu base image with few softwares installed.
i have a startup script, as below
#!/bin/bash
/usr/local/sbin/process1 -d
/usr/local/sbin/process2 -d
/bin/bash
Now I use docker-py python library to start multiple of these containers from a python file.
c = docker.Client(base_url='unix://var/run/docker.sock',
version='1.12',
timeout=10)
container = c.create_container("p12", command="/startup.sh", hostname=None, user=None,
detach=False, stdin_open=False, tty=False, mem_limit=0,
ports=None, environment=None, dns=None, volumes=None,
volumes_from=None, network_disabled=False, name=None,
entrypoint=None, cpu_shares=None, working_dir=None,
memswap_limit=0)
c.start(container, binds=None, port_bindings=None, lxc_conf=None,
publish_all_ports=False, links=None, privileged=False,
dns=None, dns_search=None, volumes_from=None, network_mode=None,
restart_policy=None, cap_add=None, cap_drop=None)
This worked fine and I can start multiple (say 3) when I tested this on a Ubuntu Desktop, Ubuntu 14.04.1 LTS and with docker-py version of 1.10. It will start the dockers and I can do a docker attach later and work on the terminal.
Now i moved my testing environment to a Ubuntu Server edition with Ubuntu 14.04.1 LTS and with docker-py version of 1.12.
The issue i see is that, when I use the same script and try to start 3 dockers, after starting process1 and process 2 as background processes, all the dockers simply exit. It appears as if /bin/bash doesnt execute at all.
If i execute the same docker image as "docker run -t -i p14 /startup.sh --> then everything is fine again. The docker is started appropriately and i get the terminal access.
The only issue is when i execute this python library.
anybody has any similar issues...any idea on how to debug this problem...or any pointers for the fix ?
Thanks,
Kiran
The difference is you're in tty (-t) mode with an open stdin (-i) when you run your docker image with docker run -t -i p14 /startup.sh, whereas you set both stdin_open=False and tty=False in your docker-py configuration.
Because your docker container has no tty and can't take any input from stdin, your call to /bin/bash has nothing to do so exits with code 0.
Try it yourself:
An open stdin with a tty
$ docker run -t -i ubuntu:14.04 /bin/bash
root#1e7eda2bba03:/# ls -la
total 7184
drwxr-xr-x 21 root root 4096 Sep 19 21:30 .
drwxr-xr-x 21 root root 4096 Sep 19 21:30 ..
-rwxr-xr-x 1 root root 0 Sep 19 21:30 .dockerenv
-rwx------ 1 root root 7279686 Jul 21 10:50 .dockerinit
drwxr-xr-x 2 root root 4096 Sep 3 03:33 bin
drwxr-xr-x 2 root root 4096 Apr 10 22:12 boot
drwxr-xr-x 4 root root 360 Sep 19 21:30 dev
drwxr-xr-x 61 root root 4096 Sep 19 21:30 etc
drwxr-xr-x 2 root root 4096 Apr 10 22:12 home
drwxr-xr-x 12 root root 4096 Sep 3 03:33 lib
drwxr-xr-x 2 root root 4096 Sep 3 03:33 lib64
drwxr-xr-x 2 root root 4096 Sep 3 03:33 media
drwxr-xr-x 2 root root 4096 Apr 10 22:12 mnt
drwxr-xr-x 2 root root 4096 Sep 3 03:33 opt
dr-xr-xr-x 240 root root 0 Sep 19 21:30 proc
drwx------ 2 root root 4096 Sep 3 03:33 root
drwxr-xr-x 7 root root 4096 Sep 3 03:33 run
drwxr-xr-x 2 root root 4096 Sep 4 18:41 sbin
drwxr-xr-x 2 root root 4096 Sep 3 03:33 srv
dr-xr-xr-x 13 root root 0 Sep 19 18:44 sys
drwxrwxrwt 2 root root 4096 Sep 4 18:41 tmp
drwxr-xr-x 10 root root 4096 Sep 3 03:33 usr
drwxr-xr-x 11 root root 4096 Sep 3 03:33 var
root#1e7eda2bba03:/#
An open stdin with no tty (i.e., no prompt, but you can still send commands via stdin)
$ docker run -i ubuntu:14.04 /bin/bash
ls -la
total 7184
drwxr-xr-x 21 root root 4096 Sep 19 21:32 .
drwxr-xr-x 21 root root 4096 Sep 19 21:32 ..
-rwxr-xr-x 1 root root 0 Sep 19 21:32 .dockerenv
-rwx------ 1 root root 7279686 Jul 21 10:50 .dockerinit
drwxr-xr-x 2 root root 4096 Sep 3 03:33 bin
drwxr-xr-x 2 root root 4096 Apr 10 22:12 boot
drwxr-xr-x 4 root root 340 Sep 19 21:32 dev
drwxr-xr-x 61 root root 4096 Sep 19 21:32 etc
drwxr-xr-x 2 root root 4096 Apr 10 22:12 home
drwxr-xr-x 12 root root 4096 Sep 3 03:33 lib
drwxr-xr-x 2 root root 4096 Sep 3 03:33 lib64
drwxr-xr-x 2 root root 4096 Sep 3 03:33 media
drwxr-xr-x 2 root root 4096 Apr 10 22:12 mnt
drwxr-xr-x 2 root root 4096 Sep 3 03:33 opt
dr-xr-xr-x 243 root root 0 Sep 19 21:32 proc
drwx------ 2 root root 4096 Sep 3 03:33 root
drwxr-xr-x 7 root root 4096 Sep 3 03:33 run
drwxr-xr-x 2 root root 4096 Sep 4 18:41 sbin
drwxr-xr-x 2 root root 4096 Sep 3 03:33 srv
dr-xr-xr-x 13 root root 0 Sep 19 18:44 sys
drwxrwxrwt 2 root root 4096 Sep 4 18:41 tmp
drwxr-xr-x 10 root root 4096 Sep 3 03:33 usr
drwxr-xr-x 11 root root 4096 Sep 3 03:33 var
A closed stdin with a tty (you can see the prompt but you can't enter any commands)
$ docker run -t ubuntu:14.04 /bin/bash
root#95904c21e5a5:/# ls -la
hello
this does nothing :(
A closed stdin with no tty - /bin/bash has nothing to do
$ docker run ubuntu:14.04 /bin/bash
$