IMPORTANT NOTE: We're starting to migrate contents of this repo to the devcontainers org, as part of the work on the open dev container specification.
We'll now be publishing the miniconda image from devcontainers/images/src/miniconda.
For more details, you can review the announcement issue.
Develop Miniconda applications in Python 3. Installs dependencies from your environment.yml file and the Python extension.
| Metadata | Value |
|---|---|
| Contributors | The VS Code Python extension team |
| Categories | Core, Languages |
| Definition type | Dockerfile |
| Published image | mcr.microsoft.com/vscode/devcontainers/miniconda:3 |
| Published image architecture(s) | x86-64 |
| Works in Codespaces | Yes |
| Container host OS support | Linux, macOS, Windows |
| Container OS | Debian |
| Languages, platforms | Python, Anaconda, Miniconda |
See history for information on the contents of published images.
While the definition itself works unmodified, you can also directly reference pre-built versions of .devcontainer/base.Dockerfile by using the image property in .devcontainer/devcontainer.json or updating the FROM statement in your own Dockerfile to the following. An example Dockerfile is included in this repository.
mcr.microsoft.com/vscode/devcontainers/minconda(orminconda:3)
You can decide how often you want updates by referencing a semantic version of each image. For example:
mcr.microsoft.com/vscode/devcontainers/miniconda:0-3mcr.microsoft.com/vscode/devcontainers/miniconda:0.201-3mcr.microsoft.com/vscode/devcontainers/miniconda:0.201.4-3
See history for information on the contents of each version and here for a complete list of available tags.
Alternatively, you can use the contents of base.Dockerfile to fully customize your container's contents or to build it for a container host architecture not supported by the image.
This dev container and its associated image includes the conda package manager. Additional packages installed using Conda will be downloaded from Anaconda or another repository if you configure one. To reconfigure Conda in this container to access an alternative repository, please see information on configuring Conda channels here.
Access to the Anaconda repository is covered by the Anaconda Terms of Service, which may require some organizations to obtain a commercial license from Anaconda. However, when this dev container or its associated image is used with GitHub Codespaces or GitHub Actions, all users are permitted to use the Anaconda Repository through the service, including organizations normally required by Anaconda to obtain a paid license for commercial activities. Note that third-party packages may be licensed by their publishers in ways that impact your intellectual property, and are used at your own risk.
Note that only the integrated terminal is supported by the Remote - Containers extension. You may need to modify launch.json configurations to include the following value if an external console is used.
"console": "integratedTerminal"By default, frameworks like Flask only listens to localhost inside the container. As a result, we recommend using the forwardPorts property (available in v0.98.0+) to make these ports available locally.
"forwardPorts": [5000]The appPort property publishes rather than forwards the port, so applications need to listen to * or 0.0.0.0 for the application to be accessible externally. This conflicts with the defaults of some Python frameworks, but fortunately the forwardPorts property does not have this limitation.
If you've already opened your folder in a container, rebuild the container using the Remote-Containers: Rebuild Container command from the Command Palette (F1) so the settings take effect.
Given JavaScript front-end web client code written for use in conjunction with a Python back-end often requires the use of Node.js-based utilities to build, this container also includes nvm so that you can easily install Node.js. You can change the version of Node.js installed or disable its installation by updating the args property in .devcontainer/devcontainer.json.
This container installs all Python development utilities using pipx to avoid impacting the global Python environment. You can use this same utility add additional utilities in an isolated environment. For example:
pipx install prospectorNote that if you change the version of Python from the default, you'll need to run a few commands to update the utilities and pipx. More on that next.
As covered in the user FAQ for Anaconda, you can install different versions of Python than the one in this image by running the following from a terminal:
conda install python=3.6
pip install --no-cache-dir pipx
pipx uninstall pipx
pipx reinstall-allOr in a Dockerfile:
RUN conda install -y python=3.6 \
&& pip install --no-cache-dir pipx \
&& pipx uninstall pipx \
&& pipx reinstall-allSee the pipx documentation for additional information.
For convenience, this definition will automatically install dependencies from the environment.yml file in the parent folder when the container is built. You can change this behavior by altering this line in the .devcontainer/Dockerfile:
RUN if [ -f "/tmp/conda-tmp/environment.yml" ]; then /opt/conda/bin/conda env update -n base -f /tmp/conda-tmp/environment.yml; fi \
&& rm -rf /tmp/conda-tmp-
If this is your first time using a development container, please see getting started information on setting up Remote-Containers or creating a codespace using GitHub Codespaces.
-
To use the pre-built image:
- Start VS Code and open your project folder or connect to a codespace.
- Press F1 select and Add Development Container Configuration Files... command for Remote-Containers or Codespaces.
- Select this definition. You may also need to select Show All Definitions... for it to appear.
-
To build a custom version of the image instead:
- Clone this repository locally.
- Start VS Code and open your project folder or connect to a codespace.
- Use your local operating system's file explorer to drag-and-drop the locally cloned copy of the
.devcontainerfolder for this definition into the VS Code file explorer for your opened project or codespace. - Update
.devcontainer/devcontainer.jsonto reference"dockerfile": "base.Dockerfile".
-
After following step 2 or 3, the contents of the
.devcontainerfolder in your project can be adapted to meet your needs. -
Finally, press F1 and run Remote-Containers: Reopen Folder in Container or Codespaces: Rebuild Container to start using the definition.
This definition includes some test code that will help you verify it is working as expected on your system. Follow these steps:
- If this is your first time using a development container, please follow the getting started steps to set up your machine.
- Clone this repository.
- Start VS Code, press F1, and select Remote-Containers: Open Folder in Container...
- Select the
containers/python-3-minicondafolder. - After the folder has opened in the container, press F5 to start the project.
- A
test-project/plot.pngfile should be added to the folder after it runs with the plot result. - Next, open
test-project/hello.pyand press ctrl/cmd+a then shift+enter. - You should see the
matplotliboutput in the interactive window. - From here, you can add breakpoints or edit the contents of the
test-projectfolder to do further testing.
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the MIT License. See LICENSE