# Usage: ENTRYPOINT application "argument", "argument", .. # Remember: arguments are optional. They can be provided by CMD # or during the creation of a container. ENTRYPOINT echo # Usage example with CMD: # Arguments set with CMD can be overridden during *run* CMD "Hello docker!" ENTRYPOINT echo
# 构建 $ docker build -t pgsql . # 查看 $ docker images REPOSITORY TAG IMAGE ID CREATED SIZE pgsql latest c79f4b0a8f78 5 minutes ago 1.38 GB # 启动容器 $ docker run -itd --name pgsql pgsql:latest /bin/bash # 查看容器 $ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 365b22da366c pgsql:latest "/bin/bash" 5 minutes ago Up 5 minutes 22/tcp, 80/tcp, 5432/tcp pgsql # 连接容器 $ docker exec -it pgsql /bin/bash [root@365b22da366c /]# chown -R postgres:postgres /usr/local/pgsql/ [root@365b22da366c /]# su - postgres [postgres@365b22da366c ~]$ cd /usr/local/pgsql/bin/ [postgres@365b22da366c bin]$ ./initdb -D ../data [postgres@365b22da366c bin]$ ./pg_ctl -D ../data/ start [postgres@365b22da366c bin]$ ./psql psql (11.2) Type "help"forhelp.
postgres=#
镜像大小
1 2 3 4
$ docker images REPOSITORY TAG IMAGE ID CREATED SIZE pgsql latest c79f4b0a8f78 10 minutes ago 1.38 GB docker.io/centos latest 9f38484d220f 10 days ago 202 MB
# Dockerfile RUNset -eux \ && wget https://ftp.postgresql.org/pub/source/v11.2/postgresql-11.2.tar.gz \ && tar zxvf postgresql-11.2.tar.gz -C /opt && rm postgresql-11.2.tar.gz \ && cd /opt/postgresql-11.2 \ && ./configure \ && make clean; make; make install \ && cd contrib \ && make clean; make; make install \ && rm -rf /opt/postgresql-11.2
$ docker build pgsql-11.2 .
$ docker images REPOSITORY TAG IMAGE ID CREATED SIZE pgsql-11.2 latest 338afc2a0a3e 2 minutes ago 383 MB
$ docker history 338afc2a0a3e IMAGE CREATED CREATED BY SIZE COMMENT 338afc2a0a3e 3 minutes ago /bin/sh -c #(nop) CMD ["/usr/sbin/sshd"] 0 B 373751418cf4 3 minutes ago /bin/sh -c #(nop) EXPOSE 80/tcp 0 B 6e555eb07f75 3 minutes ago /bin/sh -c #(nop) EXPOSE 22/tcp 0 B ae4866a01334 3 minutes ago /bin/sh -c #(nop) EXPOSE 5432/tcp 0 B 5f475c6acf58 3 minutes ago /bin/sh -c set -eux && wget https://ftp.p... 24.2 MB ec3c374d38db 10 minutes ago /bin/sh -c set -x && yum -y install bison... 157 MB efa2cda50b68 About an hour ago /bin/sh -c /bin/echo 'postgres:123456' | c... 1.83 kB a394918a64fd About an hour ago /bin/sh -c useradd postgres 296 kB 60abcd73fa1e About an hour ago /bin/sh -c /bin/echo 'root:123456' | chpasswd 1.52 kB 3c440ae01e3b About an hour ago /bin/sh -c #(nop) LABEL maintainer=yangji... 0 B 9f38484d220f 10 days ago /bin/sh -c #(nop) CMD ["/bin/bash"] 0 B <missing> 10 days ago /bin/sh -c #(nop) LABEL org.label-schema.... 0 B <missing> 10 days ago /bin/sh -c #(nop) ADD file:074f2c974463ab3... 202 MB