-
Notifications
You must be signed in to change notification settings - Fork 6
docker setup
###installation
get some docker-toolbox (https://www.docker.com/toolbox).
- run
docker-machine create -d virtualbox defaultcreates the VM - add this line
eval "$(docker-machine env default)"to your ~/.bash_profile - clone the repo you're working in (make sure you include all of the submodules)
- before you compose up the first time you will need to login to quay:
docker login quay.io
- from the root of the directory run
docker-compose upthis will build the project in your VMdocker-compose upruns in the foreground and must be left running for your environment to be active, because most applications are set up to expose port 80, you will only be able to run one at a time.
- on a fresh repository you will probably have to run one or all of
- run
docker-compose run web composer install - run
docker-compose run web npm install - run
docker-compose run web bower install --allow-root - run
docker-compose run web grunt
- run
###Managing containers and images
Docker images being used by containers will need to be force removed; if removing everything, remove containers first
- SSH into specific container docker exec -ti containerid /bin/bash
- Remove all docker containers:
docker rm $(docker ps -aq) - Remove all docker images:
docker rmi $(docker images -q) - Stop all containers:
docker kill $(docker ps -q)
###Cool Aliases
alias drun="docker-compose run web"
alias dash="docker-compose run web /bin/bash"
alias dkill="docker kill \$(docker ps -q)"
###Linux install
- These instructions are based on Linux Mint 17.2, YMMV with other distros
- You will need Apparmor before you can install docker
- run
sudo apt-get install apparmor lxc cgroup-lite - run
sudo apt-get install docker.io - Verify that your install worked
- run
sudo service docker.io start - run
sudo docker run hello-world - Install Curl
- run
sudo apt-get install curl - Use Curl to install Docker Machine
- run
sudo curl -L https://github.com/docker/machine/releases/download/v0.4.0/docker-machine_linux-amd64 > /usr/local/bin/docker-machineYou may need to run this as SU - Make docker-machine executable
- run
chmod +x /usr/local/bin/docker-machine - Use Curl to install Docker Compose
- run the command listed at https://github.com/docker/compose/releases to install the latest version of compose Run as SU
- Make docker-compose executable
- run
chmod +x /usr/local/bin/docker-compose - Create your container
- run
docker-machine create --driver=virtualbox default - Follow instructions above from second line
###docker compose basics
- if your environment gets weird you can rebuild it at any time by running
docker-compose build - to run a command in the docker container run
docker-compose run web <command>(i'm assuming the default container is named 'web', it may not be) - you can also run
docker-compose run web /bin/bashand you've basically logged into the container- or
docker-machine ssh defaultwill give you ssh access to the container
- or
- all the credentials for development will be in the
docker-compose.yml
###caveats
because of the way our dockerfiles and docker-compose configs are set up right now the file permissions need to be managed manually in development. the dockerfile will carefully set up all necessary permissions for the app to run when it builds, then when docker-compose sets up the shared folder for development it'll blow away all those files with the ones from your host filesystem. this is also why you need to run composer and npm again even though it runs during the build.
tldr: if stuff is broken try chmod -R 777 your app/storage or storage directory
There is also a known issue that causes docker machines to go screwy when switching network connections. To resolve this, try:
$ docker-machine restart default
$ eval $(docker-machine env default)
###LAN access
- turn off your docker machine vm
- run
VBoxManage modifyvm "default" --natpf1 "tcp-port8080,tcp,,8080,,80"; - turn it back on again
now you should be able to access the container from localhost:8080 or from the lan using your host machine ip address.