Виртуализация
- 1 ответ
- 0 вопросов
15
Вклад в тег
#
# MyBaseimage Dockerfile
#
# Pull base image.
FROM ubuntu:14.04
MAINTAINER Your Name <your.email@gmail.maybe>
RUN apt-get update
RUN apt-get upgrade -y
RUN apt-get install -y language-pack-en
ENV LANGUAGE en_US.UTF-8
ENV LANG en_US.UTF-8
ENV LC_ALL en_US.UTF-8
RUN locale-gen en_US.UTF-8
RUN dpkg-reconfigure locales
RUN echo "Etc/UTC" > /etc/timezone
RUN dpkg-reconfigure -f noninteractive tzdata
RUN apt-get install -y build-essential
RUN apt-get install -y python python-dev python-setuptools python-pip python-virtualenv
RUN apt-get install -y libxml2-dev wget
RUN apt-get install -y libpcre3
RUN apt-get install -y libpcre3-dev
RUN apt-get install -y libssl-dev
RUN apt-get install -y libncurses5-dev
RUN apt-get install -y git git-core
RUN apt-get install -y libpq-dev
# install nginx
RUN apt-get install -y software-properties-common python-software-properties
RUN apt-get update
docker build -t your_docker_account/your_baseimage .
#
# MyApp Dockerfile
#
# Pull base image.
FROM your_docker_account/your_baseimage
MAINTAINER Your Name <your.email@gmail.maybe>
# Set instructions on build.
RUN virtualenv /env
ADD ./ /code
RUN cd /code; /env/bin/python setup.py install
RUN cp /code/config/config.yml.docker_example /etc/code/config.yml
# Expose ports.
EXPOSE 8484
WORKDIR /code
CMD ["/env/bin/python", "app.py"]
docker build -t your_docker_account/your_app_container .
docker run -p :5432:5432 --name my_postgresdb_container -e POSTGRESQL_DB=mydb_name -e POSTGRESQL_USER=mydb_user -e POSTGRESQL_PASS=super_secret_password -d kamui/postgresql
docker run -d -p :5000:5000 \
--name my_app_container \
--link my_postgresdb_container:postgresdb \
-e DOCKERDB_ENV_POSTGRESQL_DB=mydb_name \
-e DOCKERDB_ENV_POSTGRESQL_USER=mydb_user \
-e DOCKERDB_ENV_POSTGRESQL_PASS=super_secret_password \
your_docker_account/your_app_container
docker exec -it your_app_container /bin/bash
docker logs -f your_app_container
your_app:
build: .
links:
- postgresdb
ports:
- "5000:5000"
environment:
DOCKERDB_ENV_POSTGRESQL_DB: mydb_name
DOCKERDB_ENV_POSTGRESQL_USER: mydb_user
DOCKERDB_ENV_POSTGRESQL_PASS: super_secret_password
postgresdb:
image: kamui/postgresql
ports:
- "5432:5432"
environment:
POSTGRESQL_DB: mydb_name
POSTGRESQL_USER: mydb_user
POSTGRESQL_PASS: super_secret_password
docker-compose up