I am confused about which commands (Windows 10 or Ubuntu Linux) go with each operating system install of Docker. I am using the latest Docker version on Windows 10 Pro.
For example the Docker run command:
docker run -it jupyter/tensorflow-notebook /bin/bash/
The last part of the command "bin/bash/’ linux/unix command and I am guessing that it should not be usedin a
Windows 10 Pro system. So what do I do. What do I put in its place.
I see this all the time in Docker instructions in that they give command that looks like a linux command,but what does a Windows 10 Pro user do?
For example to take a simple one. Using “ls” to see a directory work in Ubuntu/linux, but “Dir” works in Windows 10. Now there are many more, but chose some simple ones to demonstrate my point.
If you install WSL you can work in a bash console. Don’t forget to set the context that it points to your Windows host. This is much easier than to translate everything to PowerShell.
When one door closes, another opens; but we often look so long and so regretfully upon the closed door that we do not see the one which has opened for us.
– Alexander Graham Bell
Think of it like this… your client computer is Windows 10 Pro but when you ssh to a remote computer in the cloud that is Linux, you must use linux commands after you login because the operating system is now linux. It is the same way when running commands in Docker containers. So when you issue the command:
docker run -it jupyter/tensorflow-notebook /bin/bash/
You are telling Docker to create a container from the image jupyter/tensorflow-notebook and then run the command /bin/bash inside that container. (everything after the image name is run inside the container not on your computer’s os) The -it flags give you an interactive terminal inside that container. You are not on Windows at that point. Look at the prompt… it’s probably just #. That’s not a Windows prompt. You would continue to use linux commands because the container is using the linux operating system. You are essentially inside of a linux computer at that point. The fact that your client is Windows has no effect just like when you ssh into a remote linux server it doesn’t matter that you came from a Windows computer, you are now on a Linux computer and need to use Linux commands.
BTW, /bin/bash puts you into a shell, (a “terminal” window much like cmd on Windows but for Unix based systems). Everything you type after that should be a unix command until you type exit which will leave the shell and places you back into your Windows environment. Just like exiting a remote server in the cloud and returning to your computer. It’s just all running inside on Windows 10 Pro instead of the cloud,.
This allow a Windows container to stay up, either when -it or -d.
Unlike Bash, CMD or powershell requires a STD-IN, otherwise it dies. Hence the above script does not ask for input, and just keeps the container alive. This means that you cannot do anything interactively in the container, so you have to use a back door, i.e., do this: docker exec -it [RunningContainerID] powershell