Skip to content

Docker init - CLI command to create all docker related files in a project folder #453

Closed

Description

@pkhanchandan

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

Activity

  1. self-assigned this
    on Feb 10, 2023
  2. madoke commented on Feb 11, 2023

    @madoke

    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:

    • Add a vanilla option, similar to npm init and git init that would just create the files with either placeholders or comments on the main configurations
    • Allow custom templating -> this opens up to the community to create and host their own templates as well as orgs with specific internal standards/guidelines for their container images (Example from create-react-app)
    $ docker init --template https://github.com/alice/docker-nextjs-template my-project
    
    Setting up Docker for your project...
    
    CREATE .dockerignore
    CREATE Dockerfile
    CREATE compose-dev.yaml
    CREATE docker-compose.yaml
    
    ✔ Docker is setup for your Project at ./my-project
    
    Run docker compose up to get started
    
    • Interactive scaffolding option: Guiding the user through a series of questions that would help them scaffold project files.
    Could not detect any framework for your project 
      Pick from a list of templates
    > Step by step setup guide
     ---
    Select base image:
    > alpine:latest
     node:19-buster-slim
     eclipse-temurin:11
     other
    ---
    Do you want to add a database ?
    > No, Continue
     postgres:latest
     mysql:latest
     other
    ...
    
  3. changed the title [-]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[/+] on Mar 3, 2023
  4. added
    docker_desktopImprovements or additions to Docker Desktop
    cliImprovements to the Docker CLI
    on Mar 3, 2023
  5. n-valverde commented on Sep 19, 2023

    @n-valverde

    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:

    • Framework chasing: new frameworks is a common thing, does docker really want to chase all frameworks for all languages out there?
    • Framework scaffolding: frameworks often come with their own scaffolding tool, imo they're in a better position to provide such tooling
    • No framework: What if I don't want to use any framework?

    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:

    • Using a template: with the proposed templating option, I could just copy/clone a template repo, would be the same result, so where's the benefit of using docker init versus git or even curl here?
    • With the interactive option, comes so much questions/issues: base image chasing, services images chasing, which services are eligible for proposal (i.e. why proposing a database), encouraging the use of latest tag, 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.
    • IDEs: All IDEs are usually capable of generating files based on templates, what is the value added by docker init here?
    • Framework scaffolding: here again I feel like frameworks are in a better position with their own scaffolding tool, which can just decide to add a docker support. It's easier for each framework to chase docker api, than for docker to chase every framework, isn't it?
  6. added and removed
    community_newNew idea raised by a community contributor
    docker_desktopImprovements or additions to Docker Desktop
    on Nov 9, 2023
  7. moved this to Shipped! Enjoy! in docker-roadmapon May 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

cliImprovements to the Docker CLIdocker init

Type

No type

Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions