docker运行redis MongoDB

  sre

redis

docker search  redis
docker pull  redis
docker run -p 6379:6379 -v /data/docker/data/redis:/data  -d redis redis-server --appendonly yes

命令说明:
-p 6379:6379 :将容器的6379端口映射到主机的6379端口
-v /data/docker/data/redis:/data :将主机中当前目录下的/data/docker/data/redis挂载到容器的/data
redis-server –appendonly yes :在容器执行redis-server启动命令,并打开redis持久化配置

docker ps 获取 CONTAINER ID 51814b9ddc26

主机IP为10.0.0.13

docker run -it redis redis-cli -h 10.0.0.13
[root@vm harbor]# docker run -it redis redis-cli -h 10.0.0.13
shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
10.0.0.13:6379> info
# Server
redis_version:4.0.2
redis_git_sha1:00000000
redis_git_dirty:0
redis_build_id:b8c0f509bdda8a05
redis_mode:standalone
os:Linux 3.10.0-693.5.2.el7.x86_64 x86_64
arch_bits:64
multiplexing_api:epoll
atomicvar_api:atomic-builtin
gcc_version:4.9.2
process_id:1
run_id:c955abaa898936b6565857687fac466255ac96cb
tcp_port:6379
uptime_in_seconds:473
uptime_in_days:0
hz:10
lru_clock:2142987
executable:/data/redis-server
config_file:

mongo

docker search mongo
docker pull mongo
docker run -p 27017:27017 -v /data/docker/data/mongo:/data/db -d mongo
docker run -it mongo mongo --host 10.0.0.13
MongoDB shell version v3.4.10
connecting to: mongodb://10.0.0.13:27017/
MongoDB server version: 3.4.10
Welcome to the MongoDB shell.

> rs.status()
{
        "ok" : 0,
        "errmsg" : "not running with --replSet",
        "code" : 76,
        "codeName" : "NoReplicationEnabled"
}
>

LEAVE A COMMENT

Captcha Code