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

Add docker support #7

Open
0phoff opened this issue Oct 24, 2017 · 3 comments
Open

Add docker support #7

0phoff opened this issue Oct 24, 2017 · 3 comments

Comments

@0phoff
Copy link

0phoff commented Oct 24, 2017

It would be nice to add support for docker containers, in the same way you have the ssh working..
Check if the current command is docker/nvidia-docker run, and get the container-name if that is the case!

I might take a stab at implementing it myself. I'll submit a pr if I'm successful!

@soyuka
Copy link
Owner

soyuka commented Oct 24, 2017

I might take a stab at implementing it myself. I'll submit a pr if I'm successful!

Feel free to do so 👍 I'm not using docker that much 😀

@0phoff
Copy link
Author

0phoff commented Oct 24, 2017

haha no problem! I just created this issue in the hope someone would create it for me 😝

@0phoff
Copy link
Author

0phoff commented Oct 29, 2017

OK, I tried to implement it, and I have a crude version working here.

I say crude, because there are a few problems that I could not solve:

  1. The script only works if you specify a container name in your command with the --name flag. I have no clue how to work without this. The problem here is that the command uses a docker daemon to actually start the container. This means that the PID from the docker run command is not related to the PID from the actual docker container. I looked at all the info from pgrep but could not find any link between the processes.
  2. The script will only display the correct user if it was set using the -u, --user flag. The reason for this is that I use the docker inspect command to get the host and user, and this command only works if you set the user this way (and thus will not work if you change user inside of the docker container with su). I think this problem might be solveable by using nsenter to switch namespaces and then using some shell dark magic to find out what user has a tty-session opened. But this sadly goes over my head...

I also 'enhanced/improved/...' the script so that it will now also work when an ssh/docker command was ran from a subprocess. Not too sure if it is useful for ssh, but I tend to run my docker containers from shell scripts, so I dont have to remember and retype all the flags I need!

I dont feel like my changes merit a pull request, but I felt like posting my progress here, so that someone that feels competent enough to fix my problems tackle this problem, knows that some things have already been done! 🤡

In the meanwhile, I'll just use my fork, as it works for me (I tend to always name containers I frequently use, and dont really use other users except for the main root one...)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants