Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open with VSCode breaks everything, Docker Environments are useless? #137

Open
arianitu opened this issue Nov 25, 2022 · 6 comments
Open
Labels
bug Something isn't working

Comments

@arianitu
Copy link

arianitu commented Nov 25, 2022

Describe the bug
If you click Open with VSCode on any container, it breaks the original container (stops whatever is running, whether its nginx or apache.) What's worse is there is no way to get your original container working again (through a restart.). There is no way to start apache or nginx afterwards? So how are you suppose to change your code and actually see the results in nginx/apache?

This means Docker Development Environments are essentially pointless? If you cannot edit your code and see the results then what exactly are Docker Development Environments doing?

Do we need to do something special to our Dockerfiles so when VSCode attaches the original program (apache/nginx) starts again? I can't find anything on this...

Is this a Docker bug or a VSCode Attach bug? I'm using a custom compose-dev.yaml which just runs a simple apache and mysql container (seems like the most basic use case of a dev environment.)

To Reproduce
Steps to reproduce the behavior:

  1. Launch a dev environment
  2. Click Open with VSCode
  3. Container is now broken (mysql, apache, etc.) is no longer running

Expected behavior
You should be able to open your web container in VSCode to change the code? What's the point of Dev Environments, seems completely useless if you cannot actually use VSCode on a Remote Container to change anything since it breaks the container anyway?

Desktop (please complete the following information):
OS: Mac OSX (M1 Pro)
Version: Ventura 13.0.1

Version of Docker Desktop:
You can find the version by clicking on the About Docker Desktop menu

Version

4.13.1 (90346)

Engine: 20.10.20

Compose: v2.12.1

Credential Helper: v0.7.0

Kubernetes: v1.25.2

Snyk: v1.1025.0


Additional context

I really don't understand Docker Development Environments if you cannot actually attach VSCode to any of the containers to edit your code.

@arianitu arianitu added the bug Something isn't working label Nov 25, 2022
@arianitu
Copy link
Author

@glours any input on this? I'm actually super confused on what Docker Development Environments are for?

@arianitu
Copy link
Author

Can you please set overrideCommand: false in the devcontainer.json that Docker Development Environments use? It's by default set to true so it will run /bin/sh -c "while sleep 1000; do :; done" instead of the original command in the Dockerfile.

This seems like a pretty big oversight.

See (https://containers.dev/implementors/json_reference/)

overrideCommand: Tells devcontainer.json supporting services / tools whether they should run /bin/sh -c "while sleep 1000; do :; done" when starting the container instead of the container’s default command (since the container can shut down if the default command fails). Set to false if the default command must run for the container to function properly. Defaults to true for when using an image Dockerfile and false when referencing a Docker Compose file.

@arianitu
Copy link
Author

Found another issue on this here #52

Please fix ASAP if possible. Let me know if there's anything I can do to assist on my end.

@goranovs
Copy link

I have the same "issue". The "Open with VSCode" button does something to the container (re-creates it) and while I can edit my code in VSCode the services are not running. I'm using https://github.com/docker/awesome-compose/tree/master/react-express-mysql.

@bglamadrid
Copy link

I have been having this same issue and this is the only place I've seen this reported. I'm coming from a Windows 10 Home 22H2 environment.

Fortunately I can workaround this by opening VSCode and attaching it to the container, instead of clicking that button in the Docker Desktop interface.
I still have to figure things out, e.g. inspect the container (json) to understand which directory I need to open.

I'd like to use the Docker Desktop interface to connect and work with them though. Why else would I have the option there?

@SkippyHub
Copy link

SkippyHub commented Jun 4, 2023

This is a major issue with docker dev containers. The issue also causes the ports to be reassigned an incremental by 1 port for any service you are running.
Also what you are expecting from docker dev containers is a break down in functionality understanding. VScode (microsofts) remote connections open its own instance of dev containers with the devcontainer.json and docker dev containers opens a compose-dev.yaml file....

so for vscode remote-containers you need to do something like this in the devcontainer.json for vscode remote-containers (but this means you are maintaining a compose yaml file and devcontainers.json):

https://containers.dev/implementors/json_reference/#compose-specific

{
    "name": "My Project",
    "dockerComposeFile": "./docker-compose.yml",
    "service": "my-service",
    "workspaceFolder": "/workspace",
    "settings": {
        "terminal.integrated.shell.linux": "/bin/bash"
    }
}

In my view microsoft remote-containers is different implementation of a docker yaml file and it should have been a service that is configured in docker yaml format which exists side by side of your other wanted docker services...
container-dev.yaml:

services:
    node:
       image:node
    vscode:
       image:vscode-devcontainer-helper

I do not work at docker, so it would be good for someone official to have input here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants