We use a Dockerfile
to build a new image. Dockerfile's make creating an image from a container easier (it's code in a file you can commit to your SCM).
Here's the Dockerfile we end up with:
FROM ubuntu:18.04
LABEL maintainer="Chris Fidao"
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update \
&& apt-get install -y gnupg tzdata \
&& echo "UTC" > /etc/timezone \
&& dpkg-reconfigure -f noninteractive tzdata
RUN apt-get update \
&& apt-get install -y curl zip unzip git supervisor sqlite3 \
nginx php7.2-fpm php7.2-cli \
php7.2-pgsql php7.2-sqlite3 php7.2-gd \
php7.2-curl php7.2-memcached \
php7.2-imap php7.2-mysql php7.2-mbstring \
php7.2-xml php7.2-zip php7.2-bcmath php7.2-soap \
php7.2-intl php7.2-readline php7.2-xdebug \
php-msgpack php-igbinary \
&& php -r "readfile('http://getcomposer.org/installer');" | php -- --install-dir=/usr/bin/ --filename=composer \
&& mkdir /run/php \
&& apt-get -y autoremove \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
We build this image from this Dockerfile in a similar way to how we commited changes to a container to make a new image.
docker build -t shippingdocker/app:latest \
-f docker/app/Dockerfile \
docker/app
We give the image a namespaced name of shippingdocker/app
and tag it latest
(the default tag, but we're being explicit here). We tell it the location of the Dockerfile with the -f
flag, and finally we set the "context" (which I'll get into more later).