Answer the question
In order to leave comments, you need to log in
How to use Docker for web development?
Good afternoon.
Until recently, I used Vagrant. But I decided to try working with Docker.
I watched several hours of reports and read several articles. But I did not get a clear understanding of how to properly organize the environment I needed. There are resources in English, but unfortunately I do not speak.
In my work I use:
1. debian, nginx, php-fpm, mariadb, drupal.
2. debian, nginx, nodejs.
Should all tasks be in different containers or in one [debian, nginx, php-fpm] container and [mariadb] in another?
If all tasks are in different containers, then how to put them all together? And what to take for the base image of wasps or scratch (empty image)?
Thanks for answers.
Answer the question
In order to leave comments, you need to log in
Good afternoon.
All, as you called them, "tasks" should be in different containers.
1. What to take for the base image?
What you use is what you take. Do you use Debian at work? Take Debian ( https://registry.hub.docker.com/_/debian/ )
2. To create your own base image that you will later use for the application, here is an example Dockerfile for you:
#
# MyBaseimage Dockerfile
#
# Pull base image.
FROM ubuntu:14.04
MAINTAINER Your Name <[email protected]>
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
#
# MyApp Dockerfile
#
# Pull base image.
FROM your_docker_account/your_baseimage
MAINTAINER Your Name <[email protected]>
# 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 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
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
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question