Skip to content

Add ability to specify custom filename to be used as Dockerfile.#2394

Closed
gurjeet wants to merge 1 commit intomoby:masterfrom
gurjeet:allow_custom_dockerfile
Closed

Add ability to specify custom filename to be used as Dockerfile.#2394
gurjeet wants to merge 1 commit intomoby:masterfrom
gurjeet:allow_custom_dockerfile

Conversation

@gurjeet
Copy link
Contributor

@gurjeet gurjeet commented Oct 25, 2013

Now one can perform the following commands in the same directory:

docker build -t db_container -f db.dockerfile .
docker build -t web_container -f web.dockerfile .
docker build -t client_container -f client.dockerfile .
docker build -t client_container .

The last one will use the default Dockerfile file.

Now one can perform the following commands in the same directory:

    docker built -t db_container -f db.dockerfile .
    docker built -t web_container -f web.dockerfile .
    docker built -t client_container -f client.dockerfile .
    docker built -t client_container .

The last one will use the default Dockerfile file.
@gurjeet
Copy link
Contributor Author

gurjeet commented Oct 25, 2013

I have based this branch on v0.6.4 tag. Performed tests as described in [1].

The test output of the unpatched and patched binaries looks almost same, except for the timestamp differences and container ID diffs.

[1] http://docs.docker.io/en/latest/contributing/devenvironment/

@gurjeet
Copy link
Contributor Author

gurjeet commented Oct 26, 2013

I forgot to add that one of the pain points I have with the dockerfile-via-stdin feature (the dash - option) is that it does not have a context with it. So, Docker wouldn't allow me to use the ADD command since ADD requires a context.

The alternative feature, and possibly easier to accept in core, would be allow the stdin option to have a context with it. Say, -context some_dir/, and only in case of stdin processing, Docker frontend would tar the optional some_dir/ as context and sent to the backend.

@gurjeet
Copy link
Contributor Author

gurjeet commented Oct 26, 2013

Looks like commit wagerlabs/docker@65694e801a7b80930961d70c69cba9f2465459be will make it very easy to add new commands. Thankfully I did not put in a lot of effort in this commit, only to redo it using the new parser support :)

@shykes
Copy link
Contributor

shykes commented Nov 11, 2013

@gurjeet, I am not comfortable merging this because it breaks the 1-to-1 relationship between a source directory and the resulting container image. You don't actually build a Dockerfile: you build a directory with the help of the Dockerfile inside that directory.

In your example, the correct approach is this:

docker build -t db_container ./db
docker build -t web_container ./web
docker build -t client_container ./client
docker build -t client_container .

This leaves open the problem of sharing source content between ./client and ./web for example. I don't yet have an answer to that particular problem. But 99% of the people asking me for this feature don't actually need to share source content - so all you need to do is create different directories with a Dockerfile in each.

@shykes shykes closed this Nov 11, 2013
@danmayer
Copy link

danmayer commented Feb 5, 2014

@shykes I gets building a directory but it would be nice to have a default dockerfile and others that often share the same directory structure. Especially for dockerfiles that start at a child file.

@gurjeet gurjeet deleted the allow_custom_dockerfile branch October 13, 2015 19:14
cpuguy83 pushed a commit to cpuguy83/docker that referenced this pull request May 25, 2021
    Make DNS records and queries case-insensitive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants