In [21]:
import docker
In [22]:
c = docker.Client(base_url='http://192.168.59.103:2375', version='1.13')
In [27]:
c.containers()
Out[27]:
[{u'Command': u'celery worker -A terrahub -E',
u'Created': 1409770850,
u'Id': u'd8293582d7b40bf727e49a2770eea66ba0d62265fa2bf63c8647b8486e4018ed',
u'Image': u'thcms_terrahub:latest',
u'Names': [u'/thcms_worker_1'],
u'Ports': [{u'PrivatePort': 1338, u'Type': u'tcp'},
{u'PrivatePort': 22, u'Type': u'tcp'},
{u'PrivatePort': 443, u'Type': u'tcp'},
{u'PrivatePort': 80, u'Type': u'tcp'},
{u'PrivatePort': 8000, u'Type': u'tcp'}],
u'Status': u'Up About a minute'},
{u'Command': u'/bin/bash init',
u'Created': 1409770850,
u'Id': u'5ff10c60c7c311e153e0050dcb6ef3ccd95615f71103d106a3c2c7f399bbf168',
u'Image': u'thcms_terrahub:latest',
u'Names': [u'/thcms_terrahub_1'],
u'Ports': [{u'IP': u'0.0.0.0',
u'PrivatePort': 22,
u'PublicPort': 1338,
u'Type': u'tcp'},
{u'IP': u'0.0.0.0',
u'PrivatePort': 80,
u'PublicPort': 8000,
u'Type': u'tcp'},
{u'PrivatePort': 1338, u'Type': u'tcp'},
{u'PrivatePort': 443, u'Type': u'tcp'},
{u'PrivatePort': 8000, u'Type': u'tcp'}],
u'Status': u'Up About a minute'},
{u'Command': u'/var/lib/postgresql/postgres.sh',
u'Created': 1409770849,
u'Id': u'd1380b9ce826c1486335809705dbf73c6c71d6219dca9872076dbaeec943b7b4',
u'Image': u'jamesbrink/postgresql:latest',
u'Names': [u'/thcms_postgis_1',
u'/thcms_terrahub_1/postgis',
u'/thcms_terrahub_1/postgis_1',
u'/thcms_terrahub_1/thcms_postgis_1',
u'/thcms_worker_1/postgis',
u'/thcms_worker_1/postgis_1',
u'/thcms_worker_1/thcms_postgis_1'],
u'Ports': [{u'PrivatePort': 5432, u'Type': u'tcp'}],
u'Status': u'Up About a minute'},
{u'Command': u'redis-server /etc/redis/redis.conf',
u'Created': 1409770847,
u'Id': u'dc5c9440c5dbd954eaafaf206c262f671306c37b67233e2a8dda4f7c366bd5b9',
u'Image': u'dockerfile/redis:latest',
u'Names': [u'/thcms_redis_1',
u'/thcms_terrahub_1/redis',
u'/thcms_terrahub_1/redis_1',
u'/thcms_terrahub_1/thcms_redis_1',
u'/thcms_worker_1/redis',
u'/thcms_worker_1/redis_1',
u'/thcms_worker_1/thcms_redis_1'],
u'Ports': [{u'PrivatePort': 6379, u'Type': u'tcp'}],
u'Status': u'Up About a minute'}]
In [29]:
c.stop('thcms_terrahub_1')
In [30]:
c.containers()
Out[30]:
[]
In [45]:
c.start('thcms_redis_1')
In [44]:
c.containers()
Out[44]:
[]
In [43]:
output = ''.join(c.attach('thcms_redis_1', stream=True))
---------------------------------------------------------------------------
KeyboardInterrupt Traceback (most recent call last)
<ipython-input-43-b836825a7c88> in <module>()
----> 1 output = ''.join(c.logs('thcms_redis_1', stream=True))
/Library/Python/2.7/site-packages/docker/client.pyc in _multiplexed_socket_stream_helper(self, response)
285 if not length:
286 break
--> 287 data = recvall(socket, length)
288 if not data:
289 break
/Library/Python/2.7/site-packages/docker/client.pyc in recvall(socket, size)
266 blocks = []
267 while size > 0:
--> 268 block = socket.recv(size)
269 if not block:
270 return None
KeyboardInterrupt:
In [47]:
print c.logs('thcms_redis_1')
[1] 03 Sep 19:00:48.259 # You requested maxclients of 10000 requiring at least 10032 max file descriptors.
[1] 03 Sep 19:00:48.259 # Redis can't set maximum open files to 10032 because of OS error: Operation not permitted.
[1] 03 Sep 19:00:48.259 # Current maximum open files is 1024. maxclients has been reduced to 4064 to compensate for low ulimit. If you need higher maxclients increase 'ulimit -n'.
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 2.8.9 (00000000/0) 64 bit
.-`` .-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in stand alone mode
|`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
| `-._ `._ / _.-' | PID: 1
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | http://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-'
[1] 03 Sep 19:00:48.259 # Server started, Redis version 2.8.9
[1] 03 Sep 19:00:48.260 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
[1] 03 Sep 19:00:48.260 * DB loaded from disk: 0.000 seconds
[1] 03 Sep 19:00:48.260 * The server is now ready to accept connections on port 6379
[1 | signal handler] (1409771053) Received SIGTERM, scheduling shutdown...
[1] 03 Sep 19:04:13.486 # User requested shutdown...
[1] 03 Sep 19:04:13.486 * Saving the final RDB snapshot before exiting.
[1] 03 Sep 19:04:13.489 * DB saved on disk
[1] 03 Sep 19:04:13.489 # Redis is now ready to exit, bye bye...
[1] 03 Sep 19:05:13.288 # You requested maxclients of 10000 requiring at least 10032 max file descriptors.
[1] 03 Sep 19:05:13.288 # Redis can't set maximum open files to 10032 because of OS error: Operation not permitted.
[1] 03 Sep 19:05:13.288 # Current maximum open files is 1024. maxclients has been reduced to 4064 to compensate for low ulimit. If you need higher maxclients increase 'ulimit -n'.
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 2.8.9 (00000000/0) 64 bit
.-`` .-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in stand alone mode
|`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
| `-._ `._ / _.-' | PID: 1
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | http://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-'
[1] 03 Sep 19:05:13.289 # Server started, Redis version 2.8.9
[1] 03 Sep 19:05:13.289 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
[1] 03 Sep 19:05:13.289 * DB loaded from disk: 0.000 seconds
[1] 03 Sep 19:05:13.289 * The server is now ready to accept connections on port 6379
[1 | signal handler] (1409771233) Received SIGTERM, scheduling shutdown...
[1] 03 Sep 19:07:13.628 # User requested shutdown...
[1] 03 Sep 19:07:13.628 * Saving the final RDB snapshot before exiting.
[1] 03 Sep 19:07:13.633 * DB saved on disk
[1] 03 Sep 19:07:13.633 # Redis is now ready to exit, bye bye...
[1] 03 Sep 19:07:39.868 # You requested maxclients of 10000 requiring at least 10032 max file descriptors.
[1] 03 Sep 19:07:39.868 # Redis can't set maximum open files to 10032 because of OS error: Operation not permitted.
[1] 03 Sep 19:07:39.868 # Current maximum open files is 1024. maxclients has been reduced to 4064 to compensate for low ulimit. If you need higher maxclients increase 'ulimit -n'.
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 2.8.9 (00000000/0) 64 bit
.-`` .-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in stand alone mode
|`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
| `-._ `._ / _.-' | PID: 1
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | http://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-'
[1] 03 Sep 19:07:39.869 # Server started, Redis version 2.8.9
[1] 03 Sep 19:07:39.869 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
[1] 03 Sep 19:07:39.869 * DB loaded from disk: 0.000 seconds
[1] 03 Sep 19:07:39.869 * The server is now ready to accept connections on port 6379
[1 | signal handler] (1409771270) Received SIGTERM, scheduling shutdown...
[1] 03 Sep 19:07:50.392 # User requested shutdown...
[1] 03 Sep 19:07:50.392 * Saving the final RDB snapshot before exiting.
[1] 03 Sep 19:07:50.395 * DB saved on disk
[1] 03 Sep 19:07:50.395 # Redis is now ready to exit, bye bye...
[1] 03 Sep 19:08:43.817 # You requested maxclients of 10000 requiring at least 10032 max file descriptors.
[1] 03 Sep 19:08:43.818 # Redis can't set maximum open files to 10032 because of OS error: Operation not permitted.
[1] 03 Sep 19:08:43.819 # Current maximum open files is 1024. maxclients has been reduced to 4064 to compensate for low ulimit. If you need higher maxclients increase 'ulimit -n'.
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 2.8.9 (00000000/0) 64 bit
.-`` .-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in stand alone mode
|`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
| `-._ `._ / _.-' | PID: 1
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | http://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-'
[1] 03 Sep 19:08:43.819 # Server started, Redis version 2.8.9
[1] 03 Sep 19:08:43.819 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
[1] 03 Sep 19:08:43.820 * DB loaded from disk: 0.000 seconds
[1] 03 Sep 19:08:43.820 * The server is now ready to accept connections on port 6379
[1 | signal handler] (1409771331) Received SIGTERM, scheduling shutdown...
[1] 03 Sep 19:08:51.680 # User requested shutdown...
[1] 03 Sep 19:08:51.680 * Saving the final RDB snapshot before exiting.
[1] 03 Sep 19:08:51.683 * DB saved on disk
[1] 03 Sep 19:08:51.683 # Redis is now ready to exit, bye bye...
[1] 03 Sep 19:09:17.798 # You requested maxclients of 10000 requiring at least 10032 max file descriptors.
[1] 03 Sep 19:09:17.798 # Redis can't set maximum open files to 10032 because of OS error: Operation not permitted.
[1] 03 Sep 19:09:17.798 # Current maximum open files is 1024. maxclients has been reduced to 4064 to compensate for low ulimit. If you need higher maxclients increase 'ulimit -n'.
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 2.8.9 (00000000/0) 64 bit
.-`` .-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in stand alone mode
|`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
| `-._ `._ / _.-' | PID: 1
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | http://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-'
[1] 03 Sep 19:09:17.799 # Server started, Redis version 2.8.9
[1] 03 Sep 19:09:17.799 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
[1] 03 Sep 19:09:17.799 * DB loaded from disk: 0.000 seconds
[1] 03 Sep 19:09:17.800 * The server is now ready to accept connections on port 6379
In [51]:
c.images(name='thcms_terrahub')
Out[51]:
[{u'Created': 1409770807,
u'Id': u'0e224f975f4305fae5c3b4c4d459d485ec3ec0bbf250e62df0c3d40a4c51fa2e',
u'ParentId': u'76696e5ed67cd55342a67a468377b3b8dd2c338fa45798cdd9f7930024d2d3d3',
u'RepoTags': [u'thcms_terrahub:latest'],
u'Size': 0,
u'VirtualSize': 1537147178}]
In [54]:
{i['Id'] for i in c.containers(all=True)}
Out[54]:
{u'5ff10c60c7c311e153e0050dcb6ef3ccd95615f71103d106a3c2c7f399bbf168',
u'605480407a97b450348d83190b24f6a4d35785cab6550647b0b532e65778e010',
u'7de587bce071c9e74d3f0d0045caa5e6f5a10f3ecb4ff14ddfd67ef5cdea5af0',
u'9e0e6f5496ea7f0f6678e4524b5fd2fe6153e0224bb601c0452f8e70ba4d3b85',
u'9e8e09d8465fb2e6a5ae39d5f1f1b25ca9185758ed3e17bcb5587b2b6f7b921a',
u'b946cca734f4ff5b6df4b5f7dff4130eda553fb11f2fba33a8e6e58b9a56f728',
u'c080edec76a43a6983d428d78a150ad9bf55e846fdbf88b2ca43df2e33ba986f',
u'c7b4ac921fe04f3162deff777cd8ad0e346b87d0f57383311a1867d9b03f94ab',
u'd1380b9ce826c1486335809705dbf73c6c71d6219dca9872076dbaeec943b7b4',
u'd7f870e4e6ca0f8c05675d64d2f443cb626d2e105ff173b1438ba2346c539f8d',
u'd8293582d7b40bf727e49a2770eea66ba0d62265fa2bf63c8647b8486e4018ed',
u'dc5c9440c5dbd954eaafaf206c262f671306c37b67233e2a8dda4f7c366bd5b9',
u'de30f70e6893a0778ac99f17eef2f6da0b2d0bae623f6b938915dfbb2bb357f0'}
In [ ]:
Content source: hydroshare/hydroshare_temp
Similar notebooks: