$ mkdir -p ~/pg10 $ cd ~/pg10 $ nano Dockerfile Скопировать текст ниже:
FROM centos:latest MAINTAINER devrim@gunduz.org # Add the PostgreSQL PGP key to verify the official yum repository packages RUN rpm --import https://yum.postgresql.org/RPM-GPG-KEY-PGDG-10 # Add PostgreSQL's repository. It contains the most recent stable release # of PostgreSQL, 10: RUN yum -q -y install https://download.postgresql.org/pub/repos/yum/testing/10/redhat/rhel-7-x86_64/pgdg-centos10-10-1.noarch.rpm # Update the Fedora and PostgreSQL repository metadata RUN yum -q -y install deltarpm RUN yum -q -y update # Install PostgreSQL 10 and some useful packages: RUN yum -q -y install postgresql10-server postgresql10-contrib procps-ng net-tools # Run the rest of the commands as the postgres user created by the postgresql10-server # package when it was yum installed USER postgres # initdb PostgreSQL 10: RUN /usr/pgsql-10/bin/initdb -D /var/lib/pgsql/10/data -A trust 2>&1 < /dev/null # Adjust PostgreSQL configuration so that remote connections to the # database are possible. RUN echo "host all all 0.0.0.0/0 md5" >> /var/lib/pgsql/10/data/pg_hba.conf # And add listen_addresses to /var/lib/pgsql/10/data/postgresql.conf RUN echo "listen_addresses='*'" >> /var/lib/pgsql/10/data/postgresql.conf # Create a PostgreSQL role named 'docker' with 'docker' as the password and # then create a database 'docker' owned by the 'docker' role. # After start, sleep for 5 secs to make sure that postmaster is started before # creating the role and database: RUN /usr/pgsql-10/bin/pg_ctl -D /var/lib/pgsql/10/data start &&\ sleep 5 &&\ psql --command "CREATE USER docker WITH SUPERUSER PASSWORD 'docker';" &&\ createdb -O docker docker # Expose the PostgreSQL port EXPOSE 5432 # Add VOLUMEs to allow backup of config, logs and databases VOLUME ["/var/lib/pgsql/10"] # Set the default command to run when starting the container CMD ["/usr/pgsql-10/bin/postgres", "-D", "/var/lib/pgsql/10/data"]
Сохранить. #$ sudo mkdir -p /var/lib/docker/volumes/1c-server/_data #$ sudo mkdir -p /var/lib/docker/volumes/1c-server2/_data Удалить все контейнеры $ docker rm -f $(docker ps -aq) Удалить все образы $ docker rmi -f $(docker images -q) $ docker images $ cd ~/pg10 $ docker build --tag pg10 . $ docker run -d --name pg_yum_test pg10:latest
$ docker exec -ti pg_yum_test bash
# /usr/pgsql-10/bin/pg_ctl stop -D /var/lib/pgsql/10/data
# /usr/pgsql-10/bin/pg_ctl start -D /var/lib/pgsql/10/data
# yum localinstall -y *.rpm --skip-broken
Запуск постоянно
$ docker run -d --name 1c-server2 --restart always --net=host --privileged --mount source=1c-server2,target=/root 1c-server2:latest Запуск разово $ docker run -d --name 1c-server --rm --net=host --privileged --mount source=1c-server,target=/root 1c-server:latest Выключение $ docker stop 1c-server
Комментариев нет:
Отправить комментарий