Docker init - CLI command to create all docker related files in a project folder #453
Description
Tell us about your request
It would be cool to have something like docker init. This command would create all docker-related assets in my project folder, with some smart defaults for me to change to my liking. It would be nice if it could detect what my stack is, and create all the required files in one go.
Which service(s) is this request for?
Docker CLI
Tell us about the problem you're trying to solve. What are you trying to do, and why is it hard?
Right now, I need to manually write Dockerfiles, and compose files when using Docker in my project. I feel like a lot of my time would be cut-short by a docker init command that creates these files for me. I would be even better if it can detect what kind of code is there in my repository and pre-fill these files with commonly used configurations. I would then tweak it to my liking.
Are you currently working around the issue?
Currently, I am googling common Dockerfiles for the stack I use. Once I have one, I'm manually creating some docker assets in my project.
Additional context
$ docker init
Detected an Angular project...
Would you like to setup Docker for your Angular project?
► Yes, Continue
No, Pick from a list of templates
Quit
Setting up Docker for your Angular project...
CREATE .dockerignore
CREATE Dockerfile
CREATE compose-dev.yaml
CREATE docker-compose.yaml
✔ Docker is setup for your Angular Project at /source/my-angular-project
Run docker compose up to get started
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsShipped! Enjoy!
Activity
madoke commentedon Feb 11, 2023
Sounds useful for scaffolding projects. It might not be easy to create a set of templates that'll fit most users because even for the same stack there can be different combinations, depending on a variety of factors like the environment these containers run, developer's preferences, company policy etc.
Here are some suggestions that could potentially improve experience:
npm initandgit initthat would just create the files with either placeholders or comments on the main configurations[-]CLI command to create all docker related files in a project folder[/-][+]Docker init - CLI command to create all docker related files in a project folder[/+]n-valverde commentedon Sep 19, 2023
Hello, I don't really understand the purpose of this feature.
The first proposal seems oriented toward language framework selection, which I think is a bad idea for several reasons. Some of these reasons are already pointed out by @madoke . I could add:
At the end, the framework concept feels out of scope for docker in my opinion.
The second proposal does make some sense though, but trying to think about it leads me to the only conclusion that I would probably never use it. Here's some why:
docker initversusgitor evencurlhere?latesttag, chasing image documentation (if you want to provide a database selection for example, you'll need to have the correct port etc...), and the list goes on.docker inithere?