Intellij Idea 某些devcontainer映像在IntelliJ中不起作用

2w3kk1z5  于 2023-10-15  发布在  其他
关注(0)|答案(1)|浏览(250)

我有一个在VSCode中工作的devcontainer,但我不能让相同的图像在IntelliJ IDE中工作。我试着检查系统要求,我认为图像符合要求。在IntelliJ中,一个映像是否需要其他东西来用作devcontainer?
我已经尝试了PyCharm 2023.2.1 Pro和IntelliJ IDEA 2023.2.1 Ultimate。我尝试使用mcr.microsoft.com/devcontainers/universal:2-linux镜像,因为它在GitHub代码空间中不算作存储空间。当我尝试使用openjdk:11图像时,它工作正常。
下面是我尝试创建一个dev容器时的显示:

Deploying 'Dev Container'…
Creating container…
Container Id: 137057385eae5fd7eeb5fa53f3c47248f481a9095ad8ad31d840adb78a92dd1f
Container name: '/suspicious_galileo'
Starting container '/suspicious_galileo'
'Dev Container' has been deployed successfully.
Preparing environment...
Environment is successfully prepared...
Status 409: {"message":"Container 137057385eae5fd7eeb5fa53f3c47248f481a9095ad8ad31d840adb78a92dd1f is not running"}

以下是完整的devcontainer.json

{
    "name": "udjango",
    "image": "mcr.microsoft.com/devcontainers/universal:2-linux"
}
r55awzrz

r55awzrz1#

看起来问题在于GitHub默认图像有这个奇怪的入口点:

"Entrypoint": [
                "/usr/local/share/docker-init.sh",
                "/usr/local/share/ssh-init.sh"
            ]

如果我在自己的Dockerfile中覆盖入口点,那么它似乎可以在VSCode,GitHub代码空间和IntelliJ IDE中工作。
以下是完整的devcontainer.json

{
    "name": "udjango",
    "build": {
        "dockerfile": "Dockerfile"
    },
    "postCreateCommand": ["pipenv", "install"],
    "customizations": {
        "vscode": {
            "settings": {
                "terminal.integrated.defaultProfile.linux": "bash (2)",
                "terminal.integrated.profiles.linux": {
                    "bash (2)": {
                        "path": "/home/codespace/.python/current/bin/pipenv-shell"
                    }
                }
            }
        }
    }
}

以下是完整的Dockerfile

FROM mcr.microsoft.com/devcontainers/universal:2-linux

RUN python -m pip install pipenv && \
    printf "export PIPENV_SHELL=bash\npipenv shell" >/home/codespace/.python/current/bin/pipenv-shell && \
    chmod +x /home/codespace/.python/current/bin/pipenv-shell

ENTRYPOINT bash

相关问题