Last active
November 9, 2015 10:26
-
-
Save viztastic/102c54b6cca7a8ddc60c to your computer and use it in GitHub Desktop.
Notes on Docker setup.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
===================== | |
Shortcut to stop, remove all containers and images | |
===================== | |
docker stop $(docker ps -a -q) && docker rm $(docker ps -a -q) && docker rmi $(docker images -q) | |
====================== | |
Create independent directory containing Redis setup: | |
====================== | |
- Dockerfile | |
- redis.conf | |
- supervisor.conf | |
====================== | |
REDIS container Dockerfile: | |
====================== | |
FROM ubuntu:14.04 | |
RUN apt-get update -y && apt-get install -y wget build-essential | |
RUN apt-get install -y supervisor | |
RUN cd /opt && wget http://download.redis.io/releases/redis-3.0.5.tar.gz | |
RUN cd /opt && tar -xvzf redis-3.0.5.tar.gz && rm redis-3.0.5.tar.gz | |
RUN cd /opt/redis-3.0.5 && make | |
RUN mkdir -p /var/log/supervisor | |
# I have to do /data/redis or I get an error saying that redis couldn't chdir to /data/redis | |
RUN mkdir -p /data/redis | |
ADD supervisor.conf /etc/supervisor/conf.d/supervisor.conf | |
ADD redis.conf /opt/redis-3.0.5/redis.conf | |
EXPOSE 6379 | |
CMD "/usr/bin/supervisord" | |
====================== | |
REDIS redis.conf | |
====================== | |
https://github.com/InconceivableDuck/Nodevember/blob/master/redis/redis.conf | |
====================== | |
REDIS supervisor.conf | |
====================== | |
[supervisord] | |
nodaemon=true | |
[program:redis] | |
command=/opt/redis-3.0.5/src/redis-server /opt/redis-3.0.5/redis.conf | |
====================== | |
Pop into the directory and run: | |
docker build -t viztastic/redis:1.0 . | |
If you can't docker without sudo, then: | |
$ sudo groupadd docker | |
$ sudo gpasswd -a ${USER} docker | |
$ sudo service docker restart | |
(also a logout and login) | |
============= | |
Running the container: | |
============= | |
$ mkdir -p /mnt/data/redis | |
$ docker run -d -v /mnt/data:/data -p 6379:6379 redis | |
================ | |
User Docker-bash to login to containers easily: | |
================ | |
// Install | |
$ curl --fail -L -O https://github.com/phusion/baseimagedocker/ | |
archive/master.tar.gz && \ | |
tar xzf master.tar.gz && \ | |
sudo ./baseimage-docker-master/install-tools.sh | |
// Use | |
$ docker ps | |
/// get ID of container | |
$ docker-bash [CONTAINER_ID] | |
# supervisorctl |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment