dockertoolbox启动redis镜像

这篇文章主要是一些步骤演示:前提是你已经把redis镜像下载下来了。

1、 运行一个redis容器,这里发现失败了
Administrator@H0I35FAU8AJMMUT MINGW64 ~
$ docker run --name test-redis -d redis
D:\APPDev\DockerToolBox\Docker Toolbox\docker.exe: Error response from daemon: Conflict. The contain
er name "/test-redis" is already in use by container "63dee07e1d9ee17ef0cc87b0ff22fe20ffcf55721c1f02
5077775a4ae7565f7f". You have to remove (or rename) that container to be able to reuse that name.
See 'D:\APPDev\DockerToolBox\Docker Toolbox\docker.exe run --help'.

2、查看所有运行中的容器列表,发现 test-redis 没有在运行中
Administrator@H0I35FAU8AJMMUT MINGW64 ~
$ docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS
PORTS               NAMES

3、查看运行和停止中的容器列表,找到了停止状态的 test-redis
Administrator@H0I35FAU8AJMMUT MINGW64 ~
$ docker ps -a
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS
          PORTS               NAMES
63dee07e1d9e        redis               "docker-entrypoint..."   10 days ago         Exited (0) 10 d
ays ago                       test-redis

4、我们把他启动
Administrator@H0I35FAU8AJMMUT MINGW64 ~
$ docker start test-redis
test-redis

5、再次查看状态,能看到他了
Administrator@H0I35FAU8AJMMUT MINGW64 ~
$ docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS
     PORTS               NAMES
63dee07e1d9e        redis               "docker-entrypoint..."   10 days ago         Up 8 seconds
     6379/tcp            test-redis

6、端口映射
Administrator@H0I35FAU8AJMMUT MINGW64 ~
$ docker run -d -p 6378:6379 --name port-redis redis
937b0be84913412930fb499e7f09d129b0eca6212204aa72b2c01126b616090e

7、查看容器日志
Administrator@H0I35FAU8AJMMUT MINGW64 ~
$ docker logs port-redis
1:C 07 Aug 05:47:07.497 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
1:C 07 Aug 05:47:07.498 # Redis version=4.0.1, bits=64, commit=00000000, modified=0, pid=1, just sta
rted
1:C 07 Aug 05:47:07.498 # Warning: no config file specified, using the default config. In order to s
pecify a config file use redis-server /path/to/redis.conf
1:M 07 Aug 05:47:07.500 * Running mode=standalone, port=6379.
1:M 07 Aug 05:47:07.500 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/s
ys/net/core/somaxconn is set to the lower value of 128.
1:M 07 Aug 05:47:07.500 # Server initialized
1:M 07 Aug 05:47:07.500 # 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 rebo
ot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
1:M 07 Aug 05:47:07.500 # WARNING you have Transparent Huge Pages (THP) support enabled in your kern
el. This will create latency and memory usage issues with Redis. To fix this issue run the command '
echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local
in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
1:M 07 Aug 05:47:07.500 * Ready to accept connections

8、登录容器,登陆之后我们就可以在容器中进行常规的Linux系统操作命令,还可以使用exit命令退出。
Administrator@H0I35FAU8AJMMUT MINGW64 ~
$ docker exec -it port-redis bash
root@937b0be84913:/data# redis-cli
127.0.0.1:6379> set a 99
OK
127.0.0.1:6379> get a
"99"

基本就这样介绍完了。
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值