Skip to content
ILLYAKO edited this page Dec 4, 2022 · 72 revisions

DevOps foundation

Docker, Docker Compose

Test (Unit test and Integration test)

RSpec, Capybara, Selenium

Deploy

Terraform

CI/CD Pipeline (build, test, deploy)

Jenkins

Docker

Docker Installation

Docker is a platform for running applications and their dependencies in isolated environments called containers, on nearly any operating system. Homebrew (brew.sh)for installing applications on Mac(Linux) Aptitude, YUM, and YaST are package managers that lets you install anything on the Mac

1.1. Install Homebrew $ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

1.2.1 Install Docker on Linux $ brew install cask docker //cask(third-part repository) installs Docker, Docker CLI, Docker Compose

1.2.2 Install Docker on Windows

1.3. Run Docker Desktop (Windows)

1.4. Test Docker $ docker run hello-world

The Dockerfile is a manifest that describes the image that the container will use when we run it. Docker will do a few things.

  1. The Docker reads and parses the Dockerfile.
  2. The Docker fetches the parent image that this image is going to use. If there is no parent image that you're going to use, you would start from scratch.
  3. The Docker runs any commands, within the Dockerfile that is on top of that image and lastly if defined you can set a process that runs whenever a container from that image is spun up.

All of the configuration dependencies and environment dependencies and everything that the application needs will be expressed within the Dockerfile.

Docker Hub is a repository of docker images.
'alpine' is the smallest version of the image

Dockerfiles lines:
FROM nginx:alpine #parent image:tag

MAINTAINER Illya Korotun <illya.korotun@gmail.com> #author
COPY website /website #copy context into the image host directory to the container directory
COPY nginx.conf /etc/nginx/nginx.cong #copy config file to container

EXPLOSE 80 #we want to map one(80) of the ports on my Mac to the port on the container.

Build docker image
$ docker build --tag website . # create image with tag/name "website" from "." (current directory)

Run Container
$ docker run --publish 80:80 website # publish on ports HOST:Container

Docker Compose manifest

Docker compose is a simple and lightweight platform for running multiple container applications in a single stack.

docker-compose.yml
version: '3.7' # docker compose version
services:
  website: # service name usually equals the container name
    build: # looking for Dockerfile and build image
      context: . # Dockerfile address "."-current directory
    ports: # container ports HOST:Container
      - 80:80 # Dockerfile address "."-current directory

Run docker-comose and build container
$ docker-compose run website

Up docker-comose and build container and make port maping
$ docker-compose up

Show a list of the docker-compose container running in
$ docker-compose ps
Show a list of the docker container running
$ docker ps

Clone this wiki locally