boot2docker init
boot2docker start
- The boot2docker start command will return an environment variable to be set.
export DOCKER_HOST=tcp://192.168.59.103:2375
- This container is included with boot2docker
docker run hello-world
docker pull ubuntu:14.04.1
docker run -i -t ubuntu:14.04.1 /bin/bash
Share directories on MacOS X with the Docker VM so it can share directories with the Docker containers
- Assuming you are in your home directory on MacOS X (/Users/$USERNAME), you can not directory share a directory with the Docker container.
- The Docker container is running on the Boot2Docker VM, which has different directories from MacOS X.
docker run -i -t -v $(pwd)/Documents:/mnt/Documents ubuntu:14.04.1 /bin/bash
ls /mnt/Documents
exit
Follow these instructions for creating a custom boot2docker.iso:
- https://medium.com/boot2docker-lightweight-linux-for-docker/boot2docker-together-with-virtualbox-guest-additions-da1e3ab2465c
- https://gist.github.com/mattes/2d0ffd027cb16571895c#file-dockerfile-tmpl
boot2docker stop
boot2docker stop
boot2docker download
boot2docker start
- Boot2docker is a VM running the docker daemon.
- When you expose a running port, the port is running on the boot2docker VM, not on the parent host
docker run -p 8080:8080
- To access the exposed port, find the IP of boot2docker and then connect to the shared port:
boot2docker ip
DOCKERIP=$(boot2docker ip 2>/dev/null)
- Brew will install fig 0.5.2 (brew install fig), which is NOT compatible with Docker 1.3+.
- Install fig 1.0 or newer as outline on the fig website
curl -L https://github.com/docker/fig/releases/download/1.0.1/fig-`uname -s`-`uname -m` > /usr/local/bin/fig; chmod +x /usr/local/bin/fig
brew install python
easy_install pip
pip install fig
Example from the Fig website
mkdir figtest
cd figtest
cat << EOF > app.py
from flask import Flask
from redis import Redis
import os
app = Flask(__name__)
redis = Redis(host='redis', port=6379)
@app.route('/')
def hello():
redis.incr('hits')
return 'Hello World! I have been seen %s times.' % redis.get('hits')
if __name__ == "__main__":
app.run(host="0.0.0.0", debug=True)
EOF
cat << EOF > requirements.txt
flask
redis
EOF
cat << EOF > Dockerfile
FROM python:2.7
ADD . /code
WORKDIR /code
RUN pip install -r requirements.txt
EOF
cat << EOF > fig.yml
web:
build: .
command: python app.py
ports:
- "5000:5000"
volumes:
- .:/code
links:
- redis
redis:
image: redis
EOF
fig up