-
-
Save funkotron/6025664 to your computer and use it in GitHub Desktop.
#!/bin/bash | |
# Description: Using Docker (requires docker to be installed http://www.docker.io/gettingstarted/ ), spawn a postgresql instance and a dynamically configured treeio instance | |
# Also requires postgresql client tools http://www.postgresql.org/download/linux/ubuntu/ | |
# Run chmod +x to make this file executable then run it: ./docker_create_treeio.sh | |
# Author: Adam Awan | |
# Email: [email protected] | |
# Set the port to forward for Tree.io | |
TREEIO_PORT="80" | |
# Create a PostgreSQL Instance | |
echo "Retrieving adam/pglite PostgreSQL Container..." | |
docker pull adam/pglite | |
echo "Running adam/pglite PostgreSQL Container..." | |
EXISTING_VOLUME=`cat .TREEIO_PGLITE_VOLUME_ID` | |
if [ -z $EXISTING_VOLUME ]; then | |
VOLUME_OPTION="-v /data" | |
else | |
EXISTING_VOLUME="-volumes-from $EXISTING_VOLUME" | |
fi | |
EXISTING_PASSWORD=`cat .TREEIO_PGLITE_PWD` | |
PGID=$(docker run -d -p 5432 $VOLUME_OPTION $EXISTING_VOLUME adam/pglite /init $EXISTING_PASSWORD) | |
while ! docker logs $PGID 2>/dev/null | grep PG_PASSWORD | grep -q ^PG_PASSWORD= ; do sleep 1 ; done | |
eval $(docker logs $PGID 2>/dev/null) | |
PG_PORT=$(docker port $PGID 5432) | |
if [ -z $EXISTING_VOLUME ]; then | |
# This is the first volume so save the ID and Password for later accesss | |
echo $PGID > $HOME/.TREEIO_PGLITE_VOLUME_ID | |
echo $PG_PASSWORD > $HOME/.TREEIO_PGLITE_PWD | |
fi | |
PG_HOST=`ifconfig | grep "docker" -A 1 | grep "inet" | cut -d\: -f2 | cut -d\ -f1` | |
echo "A new PostgreSQL instance is listening at IP $PG_HOST on port $PG_PORT. The admin user is postgres, the admin password is $PG_PASSWORD." | |
# Sleep for a second to give it a chance to spin up | |
sleep 1 | |
echo "Pulling the treeio container..." | |
docker pull adam/treeio | |
echo "If running Vagrant you will need to forward port $TREEIO_PORT" | |
TREEID=$(docker run -d -p 22 -p $TREEIO_PORT:5000 adam/treeio /usr/sbin/treeio $PG_HOST $PG_PORT $PG_PASSWORD) | |
SSHPORT=$(docker port $TREEID 22) | |
echo "treeio running with container ID $TREEID" | |
echo "treeio SSH running on port $SSHPORT" | |
echo "WARNING! You must change the root password of your treeio container - currently it is 'treeio'." | |
echo "You can ssh to your container by running: ssh -p $SSHPORT root@localhost" | |
echo "Once connected run passwd to change your password." | |
echo "treeio is running at http://localhost:$TREEIO_PORT with username 'admin' and password 'admin'." | |
echo "Container setup complete." |
@funkotron It works! With Ubuntu 13.04 64bit inside Virtualbox. I'm using the latest script (revision 19, I think). Great job with this! I Really appreciate it! On to setting SMTP, trying to find a way to sync calendars with google, and other good stuff. Thanks a lot!!
@sermtech Glad it works for you now, it was a long night modifying the pglite and treeio containers and reading the source of Docker's undocumented volume support to get everything working smoothly with persistence!
@funkotron sorry, for the delay, I had to re-compile my kernel,lxc and docker first. Was not in town over the
weekend. When I run the script it hangs on "cat" with the error "file or folder not found"
./docker_create_treeio.sh
Passwort:
Retrieving adam/pglite PostgreSQL Container...
Pulling repository adam/pglite
Pulling image 67813e834c695fa150a386ff72ad3353c2e996cab931a91f94b73d0258a4fe19 (latest) from adam/pglite
Pulling 67813e834c695fa150a386ff72ad3353c2e996cab931a91f94b73d0258a4fe19 metadata
Pulling 67813e834c695fa150a386ff72ad3353c2e996cab931a91f94b73d0258a4fe19 fs layer
Downloading 10.24 kB/10.24 kB (100%)
Pulling a5aaacb10419eb2788c454befa645bd187835a9a620bd1a2202f063f2af685a3 metadata
Pulling a5aaacb10419eb2788c454befa645bd187835a9a620bd1a2202f063f2af685a3 fs layer
Downloading 10.24 kB/10.24 kB (100%)
Pulling 7f1df3f6856c47805da7c632883f6e9d0628063f50c1078a03b429b322644119 metadata
Pulling 7f1df3f6856c47805da7c632883f6e9d0628063f50c1078a03b429b322644119 fs layer
Downloading 10.24 kB/10.24 kB (100%)
Pulling 363c0587e8354537f0d868f162f6ba7a9a1d13c7f297e1001a09be270f68f63c metadata
Pulling 363c0587e8354537f0d868f162f6ba7a9a1d13c7f297e1001a09be270f68f63c fs layer
Downloading 10.24 kB/10.24 kB (100%)
Pulling 2048f42eaa3e2f4f52840cd6f8bd655ae393dbc7990f1f990d98adfaccda8631 metadata
Pulling 2048f42eaa3e2f4f52840cd6f8bd655ae393dbc7990f1f990d98adfaccda8631 fs layer
Downloading 10.24 kB/10.24 kB (100%)
Pulling 12a3d2365ba4cd6a682232c2829934f3edbe7a2c3aa6f9339190f9df5e44a14d metadata
Pulling 12a3d2365ba4cd6a682232c2829934f3edbe7a2c3aa6f9339190f9df5e44a14d fs layer
Downloading 10.24 kB/10.24 kB (100%)
Pulling 5101726da51ecd09e9a46a13bd0e2f1974a72d2905cd29d8471cdbd4087617e6 metadata
Pulling 5101726da51ecd09e9a46a13bd0e2f1974a72d2905cd29d8471cdbd4087617e6 fs layer
Downloading 10.24 kB/10.24 kB (100%)
Pulling 397c53a7fd188ed68920200e71520444cc1b66fb3e5ccb8f241820c9cc0fd9ea metadata
Pulling 397c53a7fd188ed68920200e71520444cc1b66fb3e5ccb8f241820c9cc0fd9ea fs layer
Downloading 10.24 kB/10.24 kB (100%)
Pulling b469d908d32ea38463740643f69e725fe063e82d5149ef1cb7865530b80c93b7 metadata
Pulling b469d908d32ea38463740643f69e725fe063e82d5149ef1cb7865530b80c93b7 fs layer
Downloading 10.24 kB/10.24 kB (100%)
Pulling ef42e751d991bc90376d1f93067ab81797d221fb0195e7e662160da63bff1fb2 metadata
Pulling ef42e751d991bc90376d1f93067ab81797d221fb0195e7e662160da63bff1fb2 fs layer
Downloading 10.24 kB/10.24 kB (100%)
Pulling 9135201b285c4ea257723757c193fccce888b7ccf9634faa4fba4cd2d7d0154b metadata
Pulling 9135201b285c4ea257723757c193fccce888b7ccf9634faa4fba4cd2d7d0154b fs layer
Downloading 16.54 MB/16.54 MB (100%)
Running adam/pglite PostgreSQL Container...
cat: .TREEIO_PGLITE_VOLUME_ID: Datei oder Verzeichnis nicht gefunden
cat: .TREEIO_PGLITE_PWD: Datei oder Verzeichnis nicht gefunden
$ docker images -a
REPOSITORY TAG ID CREATED SIZE
adam/pglite latest 67813e834c69 36 hours ago 25.62 kB (virtual 32.98 MB)
<none> <none> 7f1df3f6856c 45 hours ago 32.77 kB (virtual 32.93 MB)
<none> <none> 9135201b285c 4 weeks ago 32.72 MB (virtual 32.72 MB)
<none> <none> a5aaacb10419 45 hours ago 25.75 kB (virtual 32.96 MB)
<none> <none> b469d908d32e 4 weeks ago 24.58 kB (virtual 32.77 MB)
<none> <none> ef42e751d991 4 weeks ago 25.47 kB (virtual 32.75 MB)
<none> <none> 12a3d2365ba4 47 hours ago 25.74 kB (virtual 32.85 MB)
<none> <none> 2048f42eaa3e 46 hours ago 24.58 kB (virtual 32.87 MB)
<none> <none> 363c0587e835 46 hours ago 25.75 kB (virtual 32.9 MB)
<none> <none> 397c53a7fd18 4 weeks ago 24.58 kB (virtual 32.8 MB)
<none> <none> 5101726da51e 47 hours ago 25.74 kB (virtual 32.82 MB)
$ docker ps -a
ID IMAGE COMMAND CREATED STATUS PORTS
c5b5331d4f69 adam/pglite:latest /init 3 minutes ago Exit 255
353678dec6b5 adam/pglite:latest /init 3 minutes ago Exit 255
ed85c4a0ecc9 adam/pglite:latest /init 9 minutes ago Exit 255
$ docker logs c5b5331d4f69
lxc-start: Invalid argument - pivot_root syscall failed
lxc-start: failed to setup pivot root
lxc-start: failed to set rootfs for 'c5b5331d4f699fe053a58499fa550c49f81362a6b2ba59b54c33e9e3bc1fd045'
lxc-start: failed to setup the container
lxc-start: invalid sequence number 1. expected 2
lxc-start: failed to spawn 'c5b5331d4f699fe053a58499fa550c49f81362a6b2ba59b54c33e9e3bc1fd045'
lxc-start: Device or resource busy - failed to remove cgroup '/sys/fs/cgroup/cpuset//lxc/c5b5331d4f699fe053a58499fa550c49f81362a6b2ba59b54c33e9e3bc1fd045'
Additional info:
# systemctl status docker.service
docker.service - Docker - The Linux container engine
Loaded: loaded (/usr/lib64/systemd/system/docker.service; enabled)
Active: active (running) since Mo 2013-07-22 02:54:27 CEST; 18s ago
Process: 13766 ExecStop=/bin/sh -c sysctl -w net.ipv4.ip_forward=0 (code=exited, status=0/SUCCESS)
Process: 13772 ExecStartPre=/bin/sh -c /sbin/sysctl -w net.ipv4.ip_forward=1 (code=exited, status=0/SUCCESS)
Process: 13769 ExecStartPre=/bin/sh -c mount --make-rprivate / (code=exited, status=0/SUCCESS)
Main PID: 13775 (docker)
CGroup: name=systemd:/system/docker.service
└─13775 /usr/bin/docker -d -p /run/docker.pid -D
Jul 22 02:54:43 SGC-Abydoss.local sh[13775]: [debug] api.go:907 Calling POST /containers/{name:.*}/attach from 127.0.0.1:50847
Jul 22 02:54:43 SGC-Abydoss.local sh[13775]: 2013/07/22 02:54:43 POST /v1.3/containers/9fb2dcc8206f/attach?logs=1&stdout=1
Jul 22 02:54:43 SGC-Abydoss.local sh[13775]: [debug] api.go:907 Calling POST /containers/{name:.*}/attach from 127.0.0.1:50848
Jul 22 02:54:43 SGC-Abydoss.local sh[13775]: 2013/07/22 02:54:43 POST /v1.3/containers/9fb2dcc8206f/attach?logs=1&stderr=1
Jul 22 02:54:44 SGC-Abydoss.local sh[13775]: [debug] network.go:318 Releasing 49153
Jul 22 02:54:44 SGC-Abydoss.local sh[13775]: 2013/07/22 02:54:44 9fb2dcc8206ff835c03fee2318aec80a749906445426b8ee6a507f915c34fe45: Failed to umount filesystem: device...source busy
Jul 22 02:54:45 SGC-Abydoss.local sh[13775]: [debug] api.go:907 Calling POST /containers/{name:.*}/attach from 127.0.0.1:50849
Jul 22 02:54:45 SGC-Abydoss.local sh[13775]: 2013/07/22 02:54:45 POST /v1.3/containers/9fb2dcc8206f/attach?logs=1&stdout=1
Jul 22 02:54:45 SGC-Abydoss.local sh[13775]: [debug] api.go:907 Calling POST /containers/{name:.*}/attach from 127.0.0.1:50850
Jul 22 02:54:45 SGC-Abydoss.local sh[13775]: 2013/07/22 02:54:45 POST /v1.3/containers/9fb2dcc8206f/attach?logs=1&stderr=1
The error in that script starts on line 13:
EXISTING_VOLUME=`cat .TREEIO_PGLITE_VOLUME_ID`
if [ -z $EXISTING_VOLUME ]; then
VOLUME_OPTION="-v /data"
else
EXISTING_VOLUME="-volumes-from $EXISTING_VOLUME"
fi
EXISTING_PASSWORD=`cat .TREEIO_PGLITE_PWD`
...
Because the files .TREEIO_PGLITE_VOLUME_ID and .TREEIO_PGLITE_PWD don't exist on my machine.
@funkotron Man, thanks so much. I really hope more people realize the relevance of this script. Tree.io is a great project, one of the most complete for project management (and free) and your script made it effortless to install. Thanks again.
@X4 I apologise I've only just seen your comment. For some reason I don't get notifications of comments on this page.
I don't think that is the error. It's expected if those files don't exist the command will not store anything in the variables but should not crash.
I believe it hangs on the next command which waits for the pglite
container to be run and greps for the password that gets returned via stdout:
PGID=$(docker run -d -p 5432 $VOLUME_OPTION $EXISTING_VOLUME adam/pglite /init $EXISTING_PASSWORD)
while ! docker logs $PGID 2>/dev/null | grep PG_PASSWORD | grep -q ^PG_PASSWORD= ; do sleep 1 ; done
I will add more print statements in between to confirm this and will try and re-run on my machine with the dot files deleted.
They really need to add notifications for gists isaacs/github#21
Hi
Thanks for releasing treeio in docker container. I've run your script, it created the container successfully but I'm getting errors when i try to view the app in browser. (ubuntu server 13.04 x64)
OperationalError at /
invalid port number: "0.0.0.0:49153"
Request Method: GET
Request URL: http://derzsidavid.tk/
Django Version: 1.3
Exception Type: OperationalError
Exception Value:
invalid port number: "0.0.0.0:49153"
Exception Location: /usr/local/lib/python2.7/dist-packages/psycopg2/init.py in connect, line 164
Python Executable: /usr/bin/python
Python Version: 2.7.3
Python Path:
['/usr/local/bin',
'/srv/treeio',
'/srv/treeio/treeio',
'/usr/lib/python2.7',
'/usr/lib/python2.7/plat-linux2',
'/usr/lib/python2.7/lib-tk',
'/usr/lib/python2.7/lib-old',
'/usr/lib/python2.7/lib-dynload',
'/usr/local/lib/python2.7/dist-packages',
'/usr/lib/python2.7/dist-packages',
'/usr/lib/python2.7/dist-packages/PIL',
'/usr/lib/pymodules/python2.7']
Server time: Wed, 27 Nov 2013 12:16:50 +0000
it looks like the port is 0.0.0.0:49153 instead of just 49153. what do i need to modify to use the correct port?
ffound the solution @http://docs.docker.io/en/latest/use/basics/
| awk -F: '{ print $2 }') goes before the end bracket in lines PG_PORT & SSHPORT. thanks again
thanks
David
Hi, funkotron! Thanks for the greate container! Installation was such a joy. But now i cant upload any file, cant generate pdfs, chat dont work =/ Do you have any suggestions how to solve this?
Thank you in advance!
Hi funkotron - your Docker image is not listed in https://index.docker.io/search?q=treeio
Hi funkotron, I am trying to install a modified tree.io via docker . Can you suggest the best approach ?
Does the script assume that it is being run my home directory. Because I see these two errors
cat: .TREEIO_PGLITE_VOLUME_ID: No such file or directory
cat: .TREEIO_PGLITE_PWD: No such file or directory
and when I checked from another shell, these two files were created on user ~ home directory.
Hi ! How can I install this on heroku ? any idea or any help ? thanks in advance
Hello every body, could you please confirm if should be work on latest ubuntu version, i had alot of errors during the installation
With the latest version of Docker this now works with a persistent database.