Detail the MAC OSX Docker development environment setup
- 2020-06-07 05:50:36
- OfStack
MAC OSX Docker development environment setup
1. Install Virtualbox download address: https: / / www virtualbox. org /
VirtualBox simplified Chinese download installation (graphic tutorials) https: / / www ofstack. com article / 95311. htm
2. Install boot2docker
$ brew install boot2docker
# It can also be installed manually :
$ curl https://raw.github.com/steeve/boot2docker/master/boot2docker > boot2docker; chmod +x boot2docker; sudo mv boot2docker /usr/local/bin
3. Install Docker
$ brew install docker
# It can also be installed manually :
$ curl -o docker http://get.docker.io/builds/Darwin/x86_64/docker-latest; chmod +x docker; sudo cp docker /usr/local/bin
4. Configure the Docker client
# If the environment is not set , run boot2docker up There are Suggestions for changing environment variables
$ boot2docker up
Waiting for VM and Docker daemon to start...
.o
Started.
Writing /xxx/.boot2docker/certs/boot2docker-vm/ca.pem
Writing /xxx/.boot2docker/certs/boot2docker-vm/cert.pem
Writing /xxx/.boot2docker/certs/boot2docker-vm/key.pem
To connect the Docker client to the Docker daemon, please set:
export DOCKER_CERT_PATH=/your/path/.boot2docker/certs/boot2docker-vm
export DOCKER_TLS_VERIFY=1
export DOCKER_HOST=tcp://192.168.888.888:2376
# The final 3 Article added to the ~/.bash_profile Can be
5. Initialize and start boot2docker
$ boot2docker init
# When you're done, you'll be able to VirtualBox see 1 called boot2docker-vm The virtual machine , I'll just use it later boot2docker Command to control the behavior of the virtual machine , Start the , Stop etc. .
$ boot2docker up
# Start the ,boot2docker-vm The virtual machine , We can in VirtualBox See the virtual machine become Running state
# Direct execution boot2docker You can see the parameters that are available
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
# This is executable
$ boot2docker ssh
7. Load the image
# First download the image file
$ wget http://10.10.888.888:8001/www-v4.0.tar
# Import into the local mirror repository
$ docker load -i /path/to/www-v4.0.tar
# To the mirror
$ docker tag c39e2433999 www:v4.0
# Start the
$ docker run --privileged -it --rm -v /your/home/path/:/home/webroot -p 80:8000 www:v4.0 /bin/bash
# Your local directory /your/home/path Map to docker Of the container /home/web/root, And their ports correspond to 80:8000
Test 8.
# Before testing, set up the corresponding executable in the local directory .
# And modify locally hosts, For example, to bind es.web.com This domain name
$ boot2docker ssh
$ ifconfig
...
# To obtain ip Then return the local binding hosts
# test
$ curl -i http://es.web.com/
# The return data indicates success