Using both Docker and Podman with the same VScode devcontainer

251 views Asked by At

I am using a devcontainer for a school project and it works pretty well. I use Podman myself, but my classmate uses Docker. I want us both to be able to use the same container. How would you go about this?

My Devcontainer.json file. Docker works when the code under "Podman" is commented out.:

{
    "name": "poetry3-poetry-pyenv",
    "build": {
        "dockerfile": "Dockerfile"
    },

    //  Features to add to the Dev Container. More info: https://containers.dev/implementors/features.
    // "features": {},

    //  Use 'forwardPorts' to make a list of ports inside the container available locally.
    "forwardPorts": [8080],

    //  Use 'postCreateCommand' to run commands after the container is created.
    "postCreateCommand": "bash ./.devcontainer/post-install.sh",

    //  Configure tool-specific properties.
    "customizations": {
        "vscode": {
            "extensions":[
            "ms-python.python",
            "njpwerner.autodocstring",
            "tamasfe.even-better-toml",
            "ms-azuretools.vscode-docker",
            "bradlc.vscode-tailwindcss"]

        }
    },
    "mounts": [
        // Re-use local Git configuration
        "source=${localEnv:HOME}/.gitconfig,target=/home/vscode/.gitconfig,type=bind,consistency=cached"
    ],

    "remoteUser": "root",
    "containerUser": "node",
    
    //Podman. Comment out when using Docker
    "workspaceMount": "source=${localWorkspaceFolder},target=/workspace,type=bind,Z",
    "workspaceFolder": "/workspace",

    "runArgs": ["--userns=keep-id"]
}

Docker container:

# FROM mcr.microsoft.com/devcontainers/base:${templateOption:imageVariant}
FROM node:18-bullseye-slim

ARG DEBIAN_FRONTEND=noninteractive
ARG USER=node

RUN DEBIAN_FRONTEND=noninteractive \
    && apt-get update \ 
    && apt-get install -y build-essential --no-install-recommends make \
        ca-certificates \
        git \
        libssl-dev \
        zlib1g-dev \
        libbz2-dev \
        libreadline-dev \
        libsqlite3-dev \
        wget \
        curl \
        llvm \
        libncurses5-dev \
        xz-utils \
        tk-dev \
        libxml2-dev \
        libxmlsec1-dev \
        libffi-dev \
        liblzma-dev
# Shap/llvm-lite dependency
RUN DEBIAN_FRONTEND=noninteractive \
    && apt-get install -y llvm-dev
# Git LFS
RUN DEBIAN_FRONTEND=noninteractive \
    && apt-get install -y git-lfs
# Python and poetry installation
USER $USER
ARG HOME="/home/$USER"
# ARG PYTHON_VERSION=${templateOption:pythonVersion}
ARG PYTHON_VERSION=3.11

ENV PYENV_ROOT="${HOME}/.pyenv"
ENV PATH="${PYENV_ROOT}/shims:${PYENV_ROOT}/bin:${HOME}/.local/bin:$PATH"

RUN echo "Starting pyenv download" \
    && curl https://pyenv.run | bash \
    && echo "Installing Python" \
    && pyenv install ${PYTHON_VERSION} \
    && echo "Setting python version as global" \
    && pyenv global ${PYTHON_VERSION} \
    && echo "downloading Poetry" \
    && curl -sSL https://install.python-poetry.org | python3 - \
    && poetry config virtualenvs.in-project true

RUN git lfs install
0

There are 0 answers