FROM mysql:5.7
WORKDIR /docker-entrypoint-initdb.d
ADD init.sql .
#/docker-entrypoint-initdb.d :官方mysql固定的目录
#init.sql . 构建时执行的脚本
[root@rabbitmq1 opt]# docker build -t mysqlnew /opt/mysql/
Sending build context to Docker daemon 3.584kB
Step 1/3 : FROM mysql:5.7
5.7: Pulling from library/mysql
d599a449871e: Pull complete
f287049d3170: Pull complete
08947732a1b0: Pull complete
96f3056887f2: Pull complete
871f7f65f017: Pull complete
1dd50c4b99cb: Pull complete
5bcbdf508448: Pull complete
02a97db830bd: Pull complete
c09912a99bce: Pull complete
08a981fc6a89: Pull complete
818a84239152: Pull complete
Digest: sha256:5779c71a4730da36f013a23a437b5831198e68e634575f487d37a0639470e3a8
Status: Downloaded newer image for mysql:5.7
---> 1e4405fe1ea9
Step 2/3 : WORKDIR /docker-entrypoint-initdb.d
---> Running in 5ec57308082d
Removing intermediate container 5ec57308082d
---> e9085dfc7273
Step 3/3 : ADD init.sql .
---> c1ab37e907e4
Successfully built c1ab37e907e4
Successfully tagged mysql:latest
[root@rabbitmq1]# docker run -d -p 3310:3306 -e MYSQL_ROOT_PASSWORD=root mysqlnew
-e:环境常量
mysql:构建的经常名称
9636ff345bde2bd1240620c87a16110883deeb456fe24392af76a4b31af14ec9
FROM centos
RUN yum install -y gcc gcc-c++ net-tools make
WORKDIR /usr/local
ADD redis-4.0.14.tar.gz .
WORKDIR /usr/local/redis-4.0.14/src
RUN make && make install
WORKDIR /usr/local/redis-4.0.14/
ADD redis-7000.conf .
EXPOSE 7000
CMD ["redis-server","redis-7000.conf"]
docker build -t myredis2 /opt/redis/
docker run -p 7006:7000 -d myredis2
[root@rabbitmq1 ~]# docker exec -it 52a36994409d redis-cli -p 7000