Boot2Docker starting Ubuntu image - docker

I am trying to get the latest Ubuntu image going om my Windows 7/Boot2Docker machine but when i try to start the image i get an error message.
exec: "C:/Program Files (x86)/Git/bin/bash": stat C:/Program Files (x86)/Git/bin/bash: no such file or directory
Full errormessage:
$ docker run -t -i ubuntu /bin/bash
exec: "C:/Program Files (x86)/Git/bin/bash": stat C:/Program Files (x86)/Git/bin/bash: no such file or directory
FATA[0000] Error response from daemon: Cannot start container 100e77a5ac95f8fb8dc55e6382e7a8cd6f946ec807e90d9efdb6fc905a046569: [8] System error: exec: "C:/Program Files (x86)/Git/bin/bash": stat C:/P
rogram Files (x86)/Git/bin/bash: no such file or directory
Any clue on how to work around this? Another image like the default Jenkins one works ok!
The Ubuntu image is pulled correctly
Running Ubuntu image after SSH:
docker#boot2docker:~$ docker run ubuntu
docker#boot2docker:~$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS

It means that somehow your $PATH (within the boot2docker session) includes "C:/Program Files (x86)/Git/bin/" before /bin.
Check the $PATH you have when running docker run --rm -it ubuntu:latest.
The fact that you manage to run the image in a boot2docker ssh session, but docker ps displays nothing seems expected.
Only a docker run --rm -it ubuntu would display a shell.
A simplt docker run would exit the shell immadiatly (non-interactive run), and the container would be in status 'Exited' (see docker ps -a output)

First of all, before you create a container, you have to run "Boot2Docker Start" to start docker virtual machine then start your container inside docker VM. follow up the instructions in this link https://docs.docker.com/installation/windows/
Second, I think that it is preferred to install docker over linux machine not windows, you will get all capabilities of docker.
Best Regards,
Ahmed

Related

`$PATH: unknown` error when mounting the current directory in Docker

I want to use Docker to manage multiple Python versions (I recently got a Mac with Apple Silicon and I use old Python environment).
Since I need to read Python scripts on Docker and save the output files (for later use outside the Docker environment), I tried to mount a folder (on my Mac) following this post.
However, it shows this error:
$ docker run --name dpython -it python-docker -v $(pwd):/tmp /bin/bash
docker: Error response from daemon: OCI runtime create failed: container_linux.go:380: starting container process caused: exec: "-v": executable file not found in $PATH: unknown.
ERRO[0000] error waiting for container: context canceled
It works without -v $(pwd):/tmp. I tried to specify different folders such as ~/ and /Users/ but they didn't work.
You must specify the volume before the image name:
$ docker run --name dpython -it -v $(pwd):/tmp python-docker /bin/bash

Missing .docker folder on Ubuntu

I followed the official guide and installed docker-ce on Ubuntu 18.04 x64.
Per the instructions on Manage Docker as a non-root user, I tried to modify the ownership of .docker folder, and got a "No such file or directory" error:
$ sudo chown "$USER":"$USER" /home/"$USER"/.docker -R
chown: cannot access '/home/eric/.docker': No such file or directory
In fact, I don't even have a .docker folder:
$ ls ~/.docker
ls: cannot access '/home/eric/.docker': No such file or directory
In an earlier step, I was able to run the hello-world container successfully:
$ sudo docker run hello-world
Hello from Docker!
This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
(amd64)
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.
To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash
Share images, automate workflows, and more with a free Docker ID:
https://hub.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/get-started/
What did I do wrong?
Having the same problem. It finally worked for me after I restarted my laptop (which is running Ubuntu 18.04). Logging out and back in wasn't enough.
Manually created the .docker folder using mkdir .docker before restarting though.
The directory .docker (and the file .docker/config.json) will be created when you successfully authenticate to a Docker registry e.g Docker Hub running the command docker login.
(This presupposes $USER is part of the group docker.)

How to Copy Files From Docker Ubuntu Container to Windows Host

I can't figure out how to copy files from a docker ubuntu container to a windows host, or vice versa.
My host is Windows 10. When I start Docker, I run the Ubuntu image using
docker run -it ubuntu bash
The documentation I've read says that the way the transfer files is with docker cp, but apparently that command doesn't exist in this ubuntu image, i.e., bash: docker: command not found.
This must be a dumb oversight on my part. Can someone please give me a little help?
You need to run docker cp command on host machine.
The command template is:
docker cp <containerId>:<src_path_inside_container> <target_host_path>

How to run application from docker container from host OS?

I'm using docker container with ubuntu:14.04 and some C++ application that I compiled inside docker container.
Is it possible to run application that is inside container from host OS(in my case Win 7)?
Something like:
docker run <path-to-binary>/mybinary -f 10 -o output.txt
UPDATE:
Yes, it's possible
docker run -it <my-image> <path-to-binary>/mybinary
So ideally I want application inside docker will be just like native applications on Windows host OS.
Also is it possible to specify files and folder in host OS as input arguments to application that docker container can't see?
UPDATE:
I tried to mount shared folder at container start
docker run -v C:\shared_with_VM:/temp my_image
and also
docker run -v "C:\shared_with_VM":/temp my_image
But I get error:
C:\Program Files\Docker Toolbox\docker.exe: Error response from daemon: Invalid
bind mount spec "C:\\shared_with_VM:/temp": invalid mode: /temp.
See 'C:\Program Files\Docker Toolbox\docker.exe run --help'.
As said here right path format on Windows should be
docker run -v /c/shared_with_VM:/temp my_image
I am not sure if I correctly understand your question...
You can mount folders from your host to the container to make it accessible from within your container:
docker run -v /host/folder:/container/ -it <image> <executable> <arguments>
For example:
docker run -v /tmp:/tmphost -it ubuntu ls -al /tmphost
# or in Windows
docker run -v //c/Users/mrgloom/Desktop/data:/tmphost -it ubuntu ls -al /tmphost
This creates the folder /container/ in your container and links it with /host/folder. You can then bidirectonally read / write files inside these folders. Your binary has to point to the input file, which might be located in /container/input.txt

docker error: /var/run/docker.sock: no such file or directory

I am new to docker. I have a shell script that loads data into impala and I want a docker file that runs builds an image and run the container.
I am on mac, installed boot2docker and have the DOCKER_HOST env set up.
bash-3.2$ docker info
Containers: 0
Images: 0
Storage Driver: aufs
Root Dir: /mnt/sda1/var/lib/docker/aufs
Dirs: 0
Execution Driver: native-0.2
Kernel Version: 3.15.3-tinycore64
Debug mode (server): true
Debug mode (client): false
Fds: 10
Goroutines: 10
EventsListeners: 0
Init Path: /usr/local/bin/docker
Sockets: [unix:///var/run/docker.sock tcp://0.0.0.0:2375]
I am trying to just installed a pre-built image using:
sudo docker pull busybox
I get this error:
sudo docker pull busybox
2014/08/18 17:56:19 Post http:///var/run/docker.sock/images/create?fromImage=busybox&tag=: dial unix /var/run/docker.sock: no such file or directory
Is something wrong with my docker setup?
When I do a docker pull busybox, It pulls the image and download is complete.
bash-3.2$ docker pull busybox
Pulling repository busybox
a9eb17255234: Download complete
fd5373b3d938: Download complete
d200959a3e91: Download complete
37fca75d01ff: Download complete
511136ea3c5a: Download complete
42eed7f1bf2a: Download complete
c120b7cab0b0: Download complete
f06b02872d52: Download complete
120e218dd395: Download complete
1f5049b3536e: Download complete
bash-3.2$ docker run busybox /bin/echo Hello Doctor
Hello Doctor
Am I missing something?
You don't need to run any docker commands as sudo when you're using boot2docker as every command passed into the boot2docker VM runs as root by default.
You're seeing the error when you're running as sudo because sudo doesn't have the DOCKER_HOST env set, only your user does.
You can confirm this by doing a:
$ env
Then a
$ sudo env
And looking for DOCKER_HOST in each output.
As for having a docker file that runs your script, something like this might work for you:
Dockerfile
FROM busybox
# Copy your script into the docker image
ADD /path/to/your/script.sh /usr/local/bin/script.sh
# Run your script
CMD /usr/local/bin/script.sh
Then you can run:
docker build -t your-image-name:your-tag .
This will build your docker image, which you can see by doing a:
docker images
Then, to run your container, you can do a:
docker run your-image-name:your-tag
This run command will start a container from the image you created with your Dockerfile and your build command and then it will finish once your script.sh has finished executing.
You can quickly setup your environment using shellinit
At your command prompt execute:
$(boot2docker shellinit)
That will populate and export the environment variables and initialize other features.
docker pull will fail if docker service is not running. Make sure it is running by
:~$ ps aux | grep docker
root 18745 1.7 0.9 284104 13976 ? Ssl 21:19 0:01 /usr/bin/docker -d
If it is not running, you can start it by
sudo service docker start
For Ubuntu 15 and above use
sudo systemctl start docker
On my MAC when I start boot2docker-vm on the terminal using
boot2docker start
I see the following
To connect the Docker client to the Docker daemon, please set:
export DOCKER_CERT_PATH=<my things>
export DOCKER_TLS_VERIFY=1
export DOCKER_HOST=tcp://<ip>:2376
After setting these environment variables I was able to run the build without the problem.
Update [2016-04-28] If you are using a the recent versions of docker you can do
eval $(docker-machine env) will set the environment
(docker-machine env will print the export statements)
I also got this error. Though, I did not use boot2docker but just installed "plain" docker on Ubuntu (see https://docs.docker.com/installation/ubuntulinux/).
I got the error ("dial unix /var/run/docker.sock: no such file or directory. Are you trying to connect to a TLS-enabled daemon without TLS?") because the docker daemon was not running, yet.
On Ubuntu, you need to start the service:
sudo service docker start
See also http://blog.arungupta.me/resolve-dial-unix-docker-sock-error-techtip64
For boot2docker on Windows, after seeing:
FATA[0000] Get http:///var/run/docker.sock/v1.18/version:
dial unix /var/run/docker.sock: no such file or directory.
Are you trying to connect to a TLS-enabled daemon without TLS?
All I did was:
boot2docker start
boot2docker shellinit
That generated:
export DOCKER_CERT_PATH=C:\Users\vonc\.boot2docker\certs\boot2docker-vm
export DOCKER_TLS_VERIFY=1
export DOCKER_HOST=tcp://192.168.59.103:2376
Finally:
boot2docker ssh
And docker works again
In Linux, first of all execute sudo service docker start in terminal.
If you're using CentOS 7, and you've installed Docker via yum, don't forget to run:
$ sudo systemctl start docker
$ sudo systemctl enable docker
This will start the server, as well as re-start it automatically on boot.
To setup your environment and to keep it for the future sessions you can do:
echo 'export DOCKER_HOST="tcp://$(boot2docker ip 2>/dev/null):2375";' >> ~/.bashrc
Then:
source ~/.bashrc
And your environment will be setup in every session
The first /var/run/docker.sock refers to the same path in your boot2docker virtual machine. Correcly write for windows /var/run/docker.sock
You, maybe the not the OP, but someone may have a directory called /var/run/docker.sock/ already due to how many times you hack and slash to get things right with docker (especially noobs). Delete that directory and try again.
This helped me on my way to getting it to work on Centos 7.
I have installed the docker using offline method and post server restart docker is not running.
So, I executed the below command it worked for me!
/usr/bin/dockerd > /dev/null
run the following commands, OS = CentOS / RHLE / Amazon Linux, etc.
sudo systemctl start docker
sudo systemctl enable docker
sudo systemctl status docker
chmod 777 /var/run/docker.sock

Resources