dockerfile
docker container exits immediately even with Console.ReadLine() in a .NET Core console application
If you switch your app to target .NET Core 2.0, you can use the Microsoft.Extensions.Hosting package to host a .NET Core console application by using the HostBuilder API to start/stop your application. Its ConsoleLifetime class would process the general application start/stop method. In order to run your app, you should implement your own IHostedService interface … Read more
npm ERR! code ENOTEMPTY while npm install
I think the following command might be more appropriate: rm -r node_modules This will remove the node_modules folder in your repository. The command npm install should work now. If you are using Webpack, you can also remove the dist folder using rm -r dist and re-build your repository.
How to show the full (not truncated) “CREATED BY” commands in “docker history” output?
Use the docker history –no-trunc option to show the full command.
How do I set environment variables during the “docker build” process?
ARG is for setting environment variables which are used during the docker build process – they are not present in the final image, which is why you don’t see them when you use docker run. You use ARG for settings that are only relevant when the image is being built, and aren’t needed by containers … Read more
Why doesn’t Python app print anything when run in a detached docker container?
Finally I found a solution to see Python output when running daemonized in Docker, thanks to @ahmetalpbalkan over at GitHub. Answering it here myself for further reference : Using unbuffered output with CMD [“python”,”-u”,”main.py”] instead of CMD [“python”,”main.py”] solves the problem; you can see the output now (both, stderr and stdout) via docker logs myapp … Read more
How to get an environment variable value into Dockerfile during “docker build”?
You should use the ARG directive in your Dockerfile which is meant for this purpose. The ARG instruction defines a variable that users can pass at build-time to the builder with the docker build command using the –build-arg <varname>=<value> flag. So your Dockerfile will have this line: ARG request_domain or if you’d prefer a default … Read more
How do I copy variables between stages of multi stage Docker build?
You got 3 options: The “ARG” solution, the “base” solution, and “file” solution. ARG version_default=v1 FROM alpine:latest as base1 ARG version_default ENV version=$version_default RUN echo ${version} RUN echo ${version_default} FROM alpine:latest as base2 ARG version_default RUN echo ${version_default} another way is to use base container for multiple stages: FROM alpine:latest as base ARG version_default ENV … Read more
How to handle specific hostname like -h option in Dockerfile
This isn’t generally possible in a Dockerfile. Depending on the software, you might be able to do some kind of work-around. For example, you could try something like RUN echo $(grep $(hostname) /etc/hosts | cut -f1) my.host.name >> /etc/hosts && install-software By setting the hostname within the same RUN command as you install the software, … Read more
Running a Docker file stored locally
The process to run Dockerfile is: docker build . -t [tag] -f /path/to/Dockerfile And then: docker run -d tag