Skip to content

Instantly share code, notes, and snippets.

@andypost
Last active August 29, 2015 14:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andypost/250a0dc480ce0e392197 to your computer and use it in GitHub Desktop.
Save andypost/250a0dc480ce0e392197 to your computer and use it in GitHub Desktop.

Docker

using docker for local development

  • get docker installed
  • pull locally a code base
  • run a docker container

http://docs.docker.com/installation/mac/ http://docs.docker.com/linux/step_two/ http://docs.docker.com/windows/step_one/

Drupal 8 container

Suggestion use "RobLoach/Dockie":https://github.com/RobLoach/Dockie

Get lastest drupal core

git clone --branch 8.0.x http://git.drupal.org/project/drupal.git drupal-core8
cd drupal-core8

Pull "dockie/drupal" or "dockie/drupal-site-install" containers

sudo docker pull dockie/drupal-site-install

Run containers within needed code base

sudo docker run -d -p 8000:80 -v $(pwd):/var/www/html:rw dockie/drupal-site-install
  • This will run container with current dir as @/var/www/html@ within container

Then you can use running container First you need to know container ID - ps -a

$ sudo docker ps -a

CONTAINER ID        IMAGE                               COMMAND             CREATED             STATUS              PORTS                                                  NAMES
6c2a1fde1ca9        dockie/drupal-site-install:latest   "supervisord -n"    5 minutes ago       Up 5 minutes        22/tcp, 3306/tcp, 0.0.0.0:8001->80/tcp                 grave_mestorf       
7630e90b111d        dockie/drupal:latest                "supervisord -n"    32 minutes ago      Up 16 minutes       3306/tcp, 0.0.0.0:2200->22/tcp, 0.0.0.0:8000->80/tcp   tender_archimedes   

Stop container

sudo docker stop 7630e90b111d

sudo docker ps -a
CONTAINER ID        IMAGE                               COMMAND             CREATED             STATUS                      PORTS                                    NAMES
6c2a1fde1ca9        dockie/drupal-site-install:latest   "supervisord -n"    6 minutes ago       Up 6 minutes                22/tcp, 3306/tcp, 0.0.0.0:8001->80/tcp   grave_mestorf       
7630e90b111d        dockie/drupal:latest                "supervisord -n"    33 minutes ago      Exited (0) 12 seconds ago                                            tender_archimedes   

Start container

sudo docker start 6c2a1fde1ca9

Execute a command within container

sudo docker exec -it 6c2a1fde1ca9 drush --version
 Drush Version   :  7.0.0 


sudo docker exec -it 6c2a1fde1ca9 bash

root@6c2a1fde1ca9:/var/www/html# pwd
/var/www/html
root@6c2a1fde1ca9:/var/www/html# mysql -proot
Warning: Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 322
Server version: 5.6.24-0ubuntu2-log (Ubuntu)

Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> \q
Bye
root@6c2a1fde1ca9:/var/www/html# exit
exit

open browser http://localhost:8000/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment