Docker Desktop 4.13.0 introduces a New Dev Environment CLI for the first time

Ajeet Singh Raina - Oct 23 '22 - - Dev Community

Docker Desktop 4.13.0 is now available for Docker developers to download and install on all the leading platforms - MacOS, Linux and Windows. It comes with the latest Kubernetes v1.25.2, Compose v2.12.0 and Snyk v1.1025.0.

This release introduced a new Docker CLI plugin for the first time called docker dev. The docker dev is a new Dev Environments CLI that lets you create, list, and run Dev Envs via the command line. It means that now it’s damn easier to integrate Dev Envs into custom scripts.

What is Dev Environment?

Dev Environment helps developers to create a configurable developer environment with all the code and tools you need to quickly get up and running. Using Dev Environment, developer can:

  • Use a container locally as a full development environment.
  • Share code (including dependencies) with your team members in one click.
  • Move quickly between branches or run them side by side in VSCode.

Test driving Docker Dev Environment CLI

Ensure that you have the latest version of Docker Desktop 4.13.0+ up and running on your laptop.

% docker dev

Usage:  docker dev [OPTIONS] COMMAND

Docker Dev Environments CLI interface

Options:
  -s, --socket string   Sets the path to the unix socket or pipe to be
                        targeted. Can also be set through the environment
                        variable DOCKER_DEV_ENVS_SOCKET_PATH
  -v, --version         Display version of the dev plugin

Management Commands:
  service     Service management on a dev environment

Commands:
  check       Check Dev Environments
  create      Create a new dev environment
  list        Lists all Dev Environments
  logs        Traces logs from a dev environment
  open        Open Dev Environment with the IDE
  rm          Removes a dev environment
  start       Starts a dev environment
  stop        Stops a dev environment
  version     Show the Docker Dev version information

Run 'docker dev COMMAND --help' for more information on a command.
unknown docker command: dev []

Enter fullscreen mode Exit fullscreen mode

Viewing the Docker Dev version information

docker dev version
Version:    v0.0.3
Git commit: 2fdb7c4
Enter fullscreen mode Exit fullscreen mode

Checking the Dev Environments

docker dev check
GIT         VSCODE        REMOTE_CONTAINERS
true        true          true
Enter fullscreen mode Exit fullscreen mode

Listing the existing Dev Environments

docker dev list 
NAME        STATUS
Enter fullscreen mode Exit fullscreen mode

Creating a New Dev Environment

docker dev create --help

Usage:  docker dev create [OPTIONS] REPOSITORY_URL

Create a new dev environment

Aliases:
  create, new

Options:
  -d, --detach   Detach creates a Dev Env without attaching to it's logs
  -o, --open     Open IDE after a successful creation
Enter fullscreen mode Exit fullscreen mode

Cloning the Awesome-compose Repository

With over 18,700 stars and 2,900 forks, awesome-compose is a popular Docker repository that contains a curated list of Docker Compose samples. It helps developers learn about Docker Compose by providing a starting point for integrating different services using a Compose file and managing their deployment with Docker Compose. This project is hosted over Docker GitHub organization, Inc and publicly open for the community to contribute and submit their compose file.

Let us pick up a sample Python/Flask app using a Redis database.


docker dev create https://github.com/docker/awesome-compose/tree/master/flask-redis
Enter fullscreen mode Exit fullscreen mode

Results:

awesome-compose-beautiful_moser
Preparing to clone inside a volume
Installing credential helpers... 
done
Cloning into '/com.docker.devenvironments.code'...
Running .docker migration
Migration: no config.json detected
Migration: project is already configured for dev envs
building compose stack
2022/10/23 16:21:09 INFO: [core] [Channel #1] Channel created
2022/10/23 16:21:09 INFO: [core] [Channel #1] original dial target is: "unix:///run/buildkit/buildkitd.sock"
2022/10/23 16:21:09 INFO: [core] [Channel #1] parsed dial target is: {Scheme:unix Authority: Endpoint:run/buildkit/buildkitd.sock URL:{Scheme:unix Opaque: User: Host: Path:/run/buildkit/buildkitd.sock RawPath: OmitHost:false ForceQuery:false RawQuery: Fragment: RawFragment:}}
2022/10/23 16:21:09 INFO: [core] [Channel #1] Channel authority set to "localhost"
2022/10/23 16:21:09 INFO: [core] [Channel #1] Resolver state updated: {
  "Addresses": [
    {
      "Addr": "/run/buildkit/buildkitd.sock",
      "ServerName": "",
      "Attributes": {},
      "BalancerAttributes": null,
      "Type": 0,
      "Metadata": null
    }
  ],
  "ServiceConfig": null,
  "Attributes": null
} (resolver returned new addresses)
2022/10/23 16:21:09 INFO: [core] [Channel #1] Channel switches to new LB policy "pick_first"
2022/10/23 16:21:09 INFO: [core] [Channel #1 SubChannel #2] Subchannel created
2022/10/23 16:21:09 INFO: [core] [Channel #1 SubChannel #2] Subchannel Connectivity change to CONNECTING
2022/10/23 16:21:09 INFO: [core] [Channel #1 SubChannel #2] Subchannel picks a new address "/run/buildkit/buildkitd.sock" to connect
2022/10/23 16:21:09 INFO: [core] pickfirstBalancer: UpdateSubConnState: 0x14000722880, {CONNECTING <nil>}
2022/10/23 16:21:09 INFO: [core] blockingPicker: the picked transport is not ready, loop back to repick
2022/10/23 16:21:09 INFO: [core] [Channel #1] Channel Connectivity change to CONNECTING
2022/10/23 16:21:09 INFO: [core] [Channel #1 SubChannel #2] Subchannel Connectivity change to READY
2022/10/23 16:21:09 INFO: [core] pickfirstBalancer: UpdateSubConnState: 0x14000722880, {READY <nil>}
2022/10/23 16:21:09 INFO: [core] [Channel #1] Channel Connectivity change to READY
2022/10/23 16:21:09 INFO: [core] [Server #4] Server created
2022/10/23 16:21:09 INFO: [core] [Server #5] Server created
#1 [internal] load .dockerignore

Enter fullscreen mode Exit fullscreen mode

Wait for few seconds and check the status of the Dev Environment.

Verifying the Dev Environment status

docker dev ls
NAME                                   STATUS
awesome-compose-beautiful_moser        running
Enter fullscreen mode Exit fullscreen mode

Wait for few seconds and you will see that the application is accessible via http://localhost:8000

Image7

You can verify Dev Environment under Docker Dashboard too.

Image9

References:

Getting Help

Have a question about Docker Desktop? Search the Docker Forum Docker Desktop tag for answers, or post a question in our Docker Community Forum.

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .