Clone this project, cd into the project dir and then:
$ echo "$(ifconfig $(VBoxManage showvminfo boot2docker-vm --machinereadable | grep hostonlyadapter | cut -d '"' -f 2) | grep inet | cut -d ' ' -f 2) localbox" >> /etc/hosts
$ echo 'alias sb="pwd
/sb.sh"' >> ~/.bash_profile
$ docker build -t sitback/web .
Change your DB host in settings.php (or equvilant) from 127.0.0.1|localhost to localbox
Grant you mysql user access from the boot2docker VM IP
####### SB Wrapper
The sb.sh is very simple CLI wrapper for common docker tasks.
It is not an orchastration tool, other projects do that. sb.sh should only be:
- a 'time saver'
- intutive set of limited commands
- easy to use for non 'backend' or fullstack devs
- optional... docker cli is good anyway right :-)
Current functionality:
-
Run a prodject in a container:
$ cd my-product/doc-root
$ sb [name] start (will run a container and mount your site doc-root)
$ sb [name] stop
$ sb [name] restart (stops, kills an old container and start a new one)
$ sb [name] exec [command] (exec a commain interactively in the container)
You're vbox only needs the default vboxnet0 network and the setting should look like this:
Man love goes to:
- Sitback.com.au
docker stop $(docker ps -q)
docker rm $(docker ps -aq)
remove unused images
docker rmi $(docker images --filter dangling=true --quiet)
docker rmi ID (you probalby want to keep base images like CentOS)
docker build -t web .
- '-t' = tag/title
- '.' = dir/url of Dockerfile
docker run -d -p 8080:80 docker/web
docker run -i -t docker/web /bin/bash
Determine boot2docker IP to point your domain to:
$ boot2docker ip
You could do something like: echo "$(boot2docker ip) mysite.com" >> /etc/hosts
Port forward: VBoxManage controlvm boot2docker-vm natpf1 "xdebug,tcp,127.0.0.1,9000,,9000"
Symlink you mysql data dir:
$ ln -s /usr/local/var/mysql /Users/huders2000/mysql
Create a data only container, mounting your simlink
$ docker create --name mysql_data -v /Users/huders2000/mysql mysql $ docker create --name mysql_data -v /usr/local/var/mysql/ mysql:5.5
Pull and run the MySQL container mounting the volume fromt the mysql_data container
$ docker run --name mysql --volumes-from mysql_data -v /var/lib/mysql:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=goldcat99 -d -p 3306:3306 mysql:5.5
- HAProxy to support multiple container projects
- Switch in sb.sh wrapper to choose PHP version
- Possibly add coding
Port forward:
$ VBoxManage controlvm boot2docker-vm natpf1 "mysql,tcp,127.0.0.1,3306,,3306"
Remove Port Foward:
$ VBoxManage modifyvm "boot2docker-vm" --natpf1 delete "mysql"