Questions tagged dockerfile

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

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
Published
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
Published
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
Published
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
Published
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
Published
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
Published
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
Published
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
Published
Categorised as docker, dockerfile Tagged ,

Fixing World-writable MySql error in Docker

I’m using docker-compose, for db I have such container defined: db: build: ../builds/mysql-5.7 environment: – MYSQL_ROOT_PASSWORD=pass – MYSQL_DATABASE= – MYSQL_USER= – MYSQL_PASSWORD= expose: – 3306 volumes: – /c/Users/marcin/dock-test/composers/l1.app/mysql/data/:/var/lib/mysql/ – /c/Users/marcin/dock-test/composers/l1.app/mysql/conf.d/:/etc/mysql/conf.d/ – /c/Users/marcin/dock-test/composers/l1.app/mysql/log/:/var/log/mysql/ My Dockerfile for this image is: # Base image FROM mysql:5.7 # Set valid file permissions – otherwise MySql won’t read those files […]

1 597 598 599 600 601 609

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
faq