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

Docker integration: Add auxiliary console with docker-exec #1039

Closed
ghost opened this issue Feb 15, 2016 · 7 comments
Closed

Docker integration: Add auxiliary console with docker-exec #1039

ghost opened this issue Feb 15, 2016 · 7 comments
Assignees
Milestone

Comments

@ghost
Copy link

ghost commented Feb 15, 2016

The console on docker VMs gives you the input/output of the docker container, which is fine.

But for debugging a shell in the running container (docker exec -ti <container-id> sh) would be very helpful. So I suggest to add an auxiliary console to such a docker-exec.

@grossmj grossmj added this to the 1.5 milestone Feb 16, 2016
@julien-duponchelle
Copy link
Contributor

I agree. This mean we need to allocate the aux port by default but it's really simplify the usage of most containers.

@julien-duponchelle
Copy link
Contributor

I will need to check if we can attach a websocket to a exec. I'm not sure the documentation is not clear on this topic.
https://docs.docker.com/engine/reference/api/docker_remote_api_v1.22/

@ghost
Copy link
Author

ghost commented Feb 28, 2016

Here a workaround for local docker usage:

Create a shell script gns3-docker-exec in /usr/local/bin (or anywhere else in $PATH)

#!/bin/sh
# starts a docker-exec shell for a given hostname

id=$(docker inspect --format '{{if eq .Config.Hostname "'$1'"}}{{.Id}}{{end}}' $(docker ps -q))

[ -n "$id" ] && exec docker exec -ti $id sh -c 'if [ -x /bin/bash ]; then exec bash; else exec sh; fi'

Then create a custom console docker-exec with xfce4-terminal --tab -T "%d_exec" -e "gns3-docker-exec %d". Adapt the terminal program, here xfce4-terminal, to your preference.

Now you can use the custom console docker-exec to connect via "docker exec" to your container.

julien-duponchelle added a commit to GNS3/gns3-server that referenced this issue Feb 29, 2016
This move the allocation of aux port to the base vm.
Also now the free of console port during the close is in the
base VM.

An aux port is allocated to the docker container but not used
for the moment.

Ref GNS3/gns3-gui#1039
@julien-duponchelle
Copy link
Contributor

Hmm the websocket is not yet available:
moby/moby#9372

I test and we can not attach to the container using websocket

julien-duponchelle added a commit to GNS3/gns3-server that referenced this issue Mar 1, 2016
julien-duponchelle added a commit that referenced this issue Mar 1, 2016
@julien-duponchelle
Copy link
Contributor

I have take a look on the source code. They need to do refactoring before adding this call to the API. I doubt it will arrive fast.

I found a solution not something very clean, but it's the best I can do :( I wrap docker exec. But no tty could be allocated.

Doc about it:
https://docs.google.com/document/d/1KGkv1Vm5EgeDusk1qS1svacpuQ1ZUQSVK3XqJ01WKGc/edit#

@ghost
Copy link
Author

ghost commented Mar 1, 2016

Thanks !!! Even when it's not perfect it's a good fallback, when you want to debug a container.

Just get those validation error, I assume aux is unknown

Failed validating 'oneOf' in schema['properties']['topology']['properties']['nodes']['items']['properties']['properties']:
    {'oneOf': [{'$ref': '#/definitions/properties_vpcs'},
               {'$ref': '#/definitions/properties_dynamips'},
               {'$ref': '#/definitions/properties_dynamips_frame_relay'},
               {'$ref': '#/definitions/properties_qemu'},
               {'$ref': '#/definitions/properties_virtualbox'},
               {'$ref': '#/definitions/properties_vmware'},
               {'$ref': '#/definitions/properties_iou'},
               {'$ref': '#/definitions/properties_docker'},
               {'$ref': '#/definitions/properties_cloud_host'}],
     'type': 'object'}

On instance['topology']['nodes'][1]['properties']:
    {'adapters': 1,
     'aux': 2003,
     'console': 2001,
     'console_type': 'telnet',
     'environment': 'FTP_UID=1000\nFTP_GID=1000',
     'image': 'ftpd:latest',
     'name': 'ftpd-1'}
Best error message: Additional properties are not allowed ('environment', 'console_type', 'image', 'adapters', 'aux' were unexpected)

@julien-duponchelle
Copy link
Contributor

Validation is fixed

@julien-duponchelle julien-duponchelle modified the milestones: 2.0, 1.5 Mar 23, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants