Questions tagged dockerfile

Explore the latest questions and answers asked by our top developers.

How do I use Docker environment variable in ENTRYPOINT array?

If I set an environment variable, say ENV ADDRESSEE=world, and I want to use it in the entry point script concatenated into a fixed string like: ENTRYPOINT [“./greeting”, “–message”, “Hello, world!”] with world being the value of the environment varible, how do I do it? I tried using “Hello, $ADDRESSEE” but that doesn’t seem to […]

By Psycho Punch
Categorised as docker, dockerfile Tagged ,

How to view logs for a docker image?

In the docker world, one can easily see logs for docker container (that is, a running image). But during image creation, one usually issues multiple commands. For example npm install commands in node projects. It would be beneficial to see logs for those commands as well. I quickly searched from the documentation, but didn’t find […]

By Ville Miekk-oja
Categorised as docker, docker-image, dockerfile Tagged , ,

How to copy folders to docker image from Dockerfile?

I tried the following command in my Dockerfile: COPY * / and got mighty surprised at the result. Seems the naive docker code traverses the directories from the glob and then dumps the each file in the target directory while respectfully ignoring my directory structure. At least that is how I understand this ticket and […]

By jonalv
Categorised as docker, dockerfile Tagged ,

Is it possible to show the `WORKDIR` when building a docker image?

We have a problem with the WORKDIR when we building a docker image. Is it possible to print the value of WORKDIR? We tried: ECHO ${WORKDIR} But there is no such instruction ECHO Source: Dockerfile Questions

By Freewind
Categorised as docker, dockerfile Tagged ,

docker: What is the default WORKDIR in a Dockerfile?

We can use WORKDIR to set a directory as work directory in Dockerfile, but what’s the default value if we don’t set? Source: Dockerfile Questions

By Freewind
Categorised as docker, dockerfile, workdir Tagged , ,

Copy multiple directories with one command

Is there any way to copy multiple directories in one command, to reduce the number of layers? E.g., instead of: COPY dirone ./dirone COPY dirtwo ./dirtwo COPY dirthree ./dirthree I want to do: COPY dirone/ dirtwo/ dirthree/ ./ However, this copies the contents of the directories… but I want to copy the directories themselves. Source: […]

By Claudiu
Categorised as copy, docker, dockerfile Tagged , ,

Is Docker Compose suitable for production?

I like the idea of modularizing an applications into containers (db, fronted, backed…) However, according to Docker docs “Compose is great for development, testing, and staging environments”. The sentence tells nothing about production environment. Thus, I am confused here. Is it better to use Dockerfile to build production image from scratch and install all LAMP […]

By Lukasz Dynowski
Categorised as docker, docker-compose, dockerfile Tagged , ,

Docker: Set container name inside Dockerfile

Is there a way that I can set what the containers name will be from inside the Dockerfile? Basically I want to always have the same name so I won’t have to run “$docker ps” after building and running an image to get its name. Source: Dockerfile Questions

By Tyler Hilbert
Categorised as docker, dockerfile Tagged ,

Referencing a dynamic argument in the Docker Entrypoint

I want to run a docker container like this: docker run –rm -it -v volume1:/target -v volume2:/backup duplicity-image backup-label This would cause the following Entrypoint do get executed: duplicity /target file:///backup/$backup-label So my question is how do I structure the ENTRYPOINT such that it can resolve the $backup-label and how do I pass the backup-label […]

Conditional ENV in Dockerfile

Is it possible to conditionally set an ENV variable in a Dockerfile based on the value of a build ARG? Ex: something like ARG BUILDVAR=sad ENV SOMEVAR=if $BUILDVAR -eq “SO”; then echo “hello”; else echo “world”; fi Update: current usage based on Mario’s answer: ARG BUILD_ENV=prod ENV NODE_ENV=production RUN if [ “${BUILD_ENV}” = “test” ]; […]

By Matthew Herbst
Categorised as docker, dockerfile Tagged ,
1 520 521 522 523 524 531

Still Have Questions?

Our dedicated development team is here for you!

We can help you find answers to your question for as low as 5$.

Contact Us