Http://www.th7.cn/system/mac/201405/56653.shtml
Mac under Docker installation and handling error cannot connect to the Docker daemon. Is ' docker-d ' running on this host? and dial unix/var/run/docker.sock:no such file or directory
Cloud hosts can choose system mirroring to quickly create a host, which is more convenient than a virtual machine, and we can do this locally because of the Docker thing. It relies on LXC (Linux Container) to get a configured Linux image from the network, and it is easy to run its own applications in an isolated system. Also because its underlying core is a LXC, you need to run a small LXC in VirtualBox under Mac OS X (here is a tiny core Linux, which runs completely in memory, only about 24MB, starting at less than 5 seconds boot2docker) virtual Machine. The next communication process is docker------boot2docker--and container, port or disk mapping is also in compliance with this relationship.
Understand the above relationship and start talking about the installation process
1. Install VirtualBox, no more speaking
2. Installing Boot2docker
Brew Install Boot2docker
Curlhttps://raw.github.com/steeve/boot2docker/master/boot2docker> Boot2docker; chmod +x Boot2docker; sudo mv Boot2docker/usr/local/bin
3. Installing Docker
Brew Install Docker
can also be manually installed
Curl-o dockerhttp://get.docker.io/builds/darwin/x86_64/docker-latest; chmod +x Docker; sudo cp Docker/usr/local/bin
4. Configure the Docker client
Export docker_host=tcp://127.0.0.1:4243
Write it down in the ~/.bash_profile, if you're using bash.
5. Boot2docker Initialization and startup
Boot2docker Init
After the completion of the VirtualBox can be seen in the name boot2docker-vm
of a virtual machine, and then just use the Boot2docker command to control the behavior of the virtual machine, start, stop and so on.
Boot2docker up
Boot, boot2docker-vm
virtual machine, can also see the virtual machine become Running state in VirtualBox
Direct execution of Boot2docker can see available parameters
Usage /usr/local/bin/boot2docker {init|start|up|save|pause|stop|restart|status|info|delete|ssh|download}
6. Start the Docker daemon
sudo docker-d
Then the executable
Boot2docker ssh, enter the password tcuser into the console of the virtual machine
The MAC starts with 4243 ports and 4243 ports in the Boot2docker virtual machine, and listens on the/var/run/docker.sock. In this way, the docking process of Docker, the Dock command is the 4243 port communication that is opened on the Mac with the Docker daemon, which maps to 4243 ports on the Boot2docker, and through/var/run/docker.sock communicates with the container therein.
Therefore, if you do not start Docker daemon when you execute Docker version, you will be prompted
2014/05/16 06:52:48 cannot connect to the Docker daemon. Is ' docker-d ' running on this host?
If not started Boot2docker will be prompted
Get http:///var/run/docker.sock/v1.11/version:dial unix/var/run/docker.sock:no such file or directory
This article original link http://unmi.cc/mac-os-x-experience-docker/, from Yehuang Unmi Blog
Now it's time to get into the dock, and there's a command for Docker here http://blog.tankywoo.com/docker/2014/05/08/docker-4-summary.html.
1. Download the image and load the boot container
Docker Images #现在没有一个镜像
Docker pull Learn/tutorial #我们把这个拉下来试验 to find all Ubuntu-related images using Docker search Ubuntu
Docker run-i-T learn/tutorial #加载镜像 learn/tutorial to the shell so that it is connected directly to the container, and the container is retired after exiting
Docker PS #在另一个终端中用这个命令, you can see the running instance, which is the container
Now we are on the console of the container [email protected]:/#, can install a apche2, curl and start apache2, to test the next
[Email protected]:/# apt-get Update
[Email protected]:/# apt-get Install apache2 Curl
[Email protected]:/# apachectl Start
[Email protected]:/# Curl http://localhost
<p>this is the default Web page for this server.</p>
<p>the Web Server software is running and no content has been added, yet.</p>
</body>
The Apache2 starts normally and is accessible within the container. However, it is not yet possible to access the Apache service from Mac OS X, which requires port mapping in two ways. However, you will need to save the changes to the mirror before port mapping.
2. Save the image
If the previous image is run with Docker run-i-T learn/tutorial, you need to open a new terminal to operate.
The software is installed in the container in which the image is run, and the new content needs to be saved to the image, not the next time the image is started and restored as it is .
[email protected] ~> Docker PS
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
95903c1a2bf7 Learn/tutorial:latest/bin/bash 6 minutes ago up 5 minutes 80/tcp Thirsty_colden
See the ID of the container and then execute
Docker commit 95903c1a2bf7 learn/tutorial:latest #把当前容器的修改提交到镜像 learn/tutorial
Running the image again later has the latest installed content.
2. Port mapping
For example, the mapping we're going to do now is Mac OS X (50080)--Boot2docker (40080)--and container (80), there are two ways to
1)
Boot2docker ssh-l 50080:localhost:40080
Docker run-i-t-p 40080:80 learn/tutorial
[Email protected]:/# apachectl Start
Then open the http://localhost:50080 in your Mac's browser
2)
Vboxmanage modifyvm "BOOT2DOCKER-VM"--NATPF1 "tcp-port_50080:80,tcp,,50080,,40080"
Docker run-i-t-p 40080:80 learn/tutorial
[Email protected]:/# apachectl Start
This is a direct modification of the BOOT2DOCKER-VM configuration, you can see this configuration in VirtualBox, configure NAT command see Http://www.virtualbox.org/manual/ch06.html#natforward. The benefit of this is that many port mappings can be established.
You can also edit the port mapping relationship directly here
In addition to using Boot2docker as a LXC, there is also a substitute for the use of Docker under Mac vagrant.
Reference:
1. Building a development environment with Docker
one of the 2.Docker learning notes to build a Java Tomcat runtime environment
3.Installing Docker on Mac OS X
4.https://github.com/boot2docker/boot2docker
5.Docker Quick Start
Docker installation under Mac