Docker安装redis
#搜索镜像
[root@localhost tom_data]# docker search redis
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
redis Redis is an open source key-value store that… 11304 [OK]
#拉取镜像
docker pull redis
#启动容器
docker run -itd --name redis-01 -p 6379:6379 redis
#进入镜像
[root@localhost tom_data]# docker exec -it redis-01 /bin/bash
root@762767f58677:/data# redis_cli
bash: redis_cli: command not found
root@762767f58677:/data# redis-cli
127.0.0.1:6379> set k2 v2
OK
127.0.0.1:6379> get k2
"v2"
自定义启动文件,并挂载目录
docker run -v /data/redis/redis.conf:/etc/redis/redis.conf \
-v /data/redis/data:/data \
-p 6379:6379 --name myredis \
redis:6.2.8 \
redis-server /etc/redis/redis.conf
#Docker 安装Nginx
#搜索镜像
[root@localhost tom_data]# docker search nginx
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
nginx Official build of Nginx. 17340 [OK]
#拉取镜像
[root@localhost tom_data]# docker pull nginx
Using default tag: latest
latest: Pulling from library/nginx
a2abf6c4d29d: Already exists
a9edb18cadd1: Pull complete
589b7251471a: Pull complete
186b1aaa4aa6: Pull complete
b4df32aa5a72: Pull complete
a0bcbecc962e: Pull complete
Digest: sha256:0d17b565c37bcbd895e9d92315a05c1c3c9a29f762b011a10c54a66cd53c9b31
Status: Downloaded newer image for nginx:latest
docker.io/library/nginx:latest
#查看镜像
[root@localhost tom_data]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
nginx latest 605c77e624dd 8 months ago 141MB
#运行镜像
[root@localhost tom_data]# docker run --name nginx-01 -p 9081:80 -d nginx
9d40d380512b8ad864a3db45191781a4f37a250f319b31d343f512e68b5677f5
#验证
[root@localhost tom_data]# curl http://localhost:9081
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>