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 can quickly setup your environment using
shellinit
At your command prompt execute:
That will populate and export the environment variables and initialize other features.
You don't need to run any docker commands as
sudo
when you're usingboot2docker
as every command passed into theboot2docker
VM runs as root by default.You're seeing the error when you're running as
sudo
becausesudo
doesn't have theDOCKER_HOST
env set, only your user does.You can confirm this by doing a:
Then a
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
Then you can run:
This will build your docker image, which you can see by doing a:
Then, to run your container, you can do a:
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 yourscript.sh
has finished executing.docker pull
will fail ifdocker service
is not running. Make sure it is running byIf it is not running, you can start it by
sudo service docker start
For Ubuntu 15 and above use
sudo systemctl start docker
To setup your environment and to keep it for the future sessions you can do:
Then:
source ~/.bashrc
And your environment will be setup in every session
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.