第一步:编辑Dockerfile
vi Dockerfile
# 写入
FROM ubuntu:latest
MAINTAINER lqz
WORKDIR /soft
RUN apt-get update && apt-get install wget make build-essential -y
RUN wget https://github.com/redis/redis/archive/7.0.11.tar.gz && tar -xzvf 7.0.11.tar.gz
WORKDIR /soft/redis-7.0.11
RUN make && make install
EXPOSE 6379
CMD ["redis-server","./redis.conf"]
第二步:执行命令构建镜像
# 构建镜像
docker build -t='ubuntu_redis' .
第三步:查看构建完成的镜像
docker images
'''
REPOSITORY TAG IMAGE ID CREATED SIZE
ubuntu_redis latest 3ef971a3ea96 15 minutes ago 615MB
'''
第四步:镜像运行成容器
docker run -id --name redis -p 6379:6379 ubuntu_redis
第五步:查看正在运行的容器
docker ps
'''
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
bce3cd443ae7 ubuntu_redis "redis-server ./redi…" 9 minutes ago Up 9 minutes 0.0.0.0:6379->6379/tcp, :::6379->6379/tcp redis
'''
第六步:进入到容器
docker exec -it redis /bin/bash
redis-cli # 连接