redis
Introduction
Redis image based on hjben/centos-systemd:latest
Usage
1. Pull image
- Pull docker image from the DockerHub, or build the image with Dockerfile.
- docker pull hjben/redis:latest
2. Run container
- Command to run redis container is below.
- docker run -d --privileged --cgroupns=host --name {container_name} -p 6379:6379 -v /sys/fs/cgroup:/sys/fs/cgroup:rw hjben/redis:latest
- e.g. docker run -d --privileged --cgroupns=host --name redis -p 6379:6379 -v /sys/fs/cgroup:/sys/fs/cgroup:rw hjben/redis:latest
- Command Description
- -d: Run with daemon (background) mode
- --privileged: Share the host permission with container
- --cgroupns=host: Privilege the host's cgroup
- --name {container_name}: Set container name to {container_name}
- -p 6379:6379: Expose 6379 port of the container
- -v /sys/fs/cgroup:/sys/fs/cgroup:rw: Share the disk volume between host and container, to access host cgroup from the container
3. Start Redis service
- In the container shell, run the command "/sh/init.sh". Then the Redis service will be started in the foreground.
- If you're in the host shell and not in the container shell, the command below maybe work for you.
- docker exec {redis_container_name} bash -c "/sh/init.sh"
- e.g. docker exec redis bash -c "/sh/init.sh"
- If you want to stop the Redis service, just exit the executed console.
4. Then, enjoy your Redis server!