Docker 101 for Developers
A comprehensive guide for managing containers
PUG Torino - 22th February 2018
PUG Torino - 22th February 2018
Docker is a containerization tool used for spinning up isolated, reproducible application environments.
Lightweight
uses the underlying host computer kernel
Distribution
easily distribute and recreate your entire development environment
Build once, run anywhere
no more ( ) environment-specific bugs
Docker is a company that provides software (also called Docker) that allows you to build, run and manage software containers
[troll_mode_on]CoreOS is dead, long live CoreOS![troll_mode_off]
Light weight and secure alternative to Docker
Low-level Linux container runtime
Implements OCI (Open Container Initiative) and based on runc or Clear Containers runtimes
Made of a set of layers,
like a Class.
A process based on an Image,
like an Instance.
namespace PhpUserGroup\Turin;
use Docker\Contracts;
use PhpUserGroup\MeetUp;
class DockerMeetUp extends MeetUp
{
public static function build(): IImage;
}
use \PhpUserGroup\Turin\DockerMeetUp;
$meetUp = new DockerMeetUp();
$anotherMeetUp = new DockerMeetUp();
$soOnMeetUp = new DockerMeetUp();
Using Dockerfile: `docker build . - t <USERNAME>/<APP>:<VERSION>`
FROM prometherion/php7-nginx:1.1.3
#
# Installing PHP needed extensions
#
USER root
RUN apt-get update && apt-get install -y \
sqlite3 \
libsqlite3-dev \
&& docker-php-ext-install \
bcmath \
pdo_mysql \
pdo_sqlite \
&& pecl install -o -f redis \
&& rm -rf /tmp/pear \
&& cat > /usr/local/etc/php/conf.d/redis.ini < EOF
extension=redis.so \
EOF \
&& composer global require hirak/prestissimo
#
# Application deployment
#
COPY . ./
docker run prometherion/php7-nginx:1.1.3
docker container ps
docker logs <CONTAINER_ID|CONTAINER_NAME>
docker run -d prometherion/php7-nginx:1.1.3
docker run -d -p 8080:8080 prometherion/php7-nginx:1.1.3
docker run \
-d -p 8080:8080 -v `pwd`:/var/www \
prometherion/php7-nginx:1.1.3
docker run -e FOO=BAR prometherion/php7-nginx:1.1.3
docker container stop <CONTAINER_ID|CONTAINER_NAME>
docker container rm <CONTAINER_ID|CONTAINER_NAME>