Docker - koglak/SWE573 GitHub Wiki

Docker is a software platform that allows you to quickly build, test, and deploy your applications. Docker packages software in standardized units called containers that contain everything necessary for the software to run, including libraries, system tools, code, and runtime. Using Docker, you can quickly deploy applications to any environment, scale applications, and be confident that your code will work.

Developers can create containers without Docker, but the platform makes it easier, simpler, and safer to build, deploy and manage containers. Docker is essentially a toolkit that enables developers to build, deploy, run, update, and stop containers using simple commands and work-saving automation through a single API.

DockerFile

Every Docker container starts with a simple text file containing instructions for how to build the Docker container image. DockerFile automates the process of Docker image creation. It’s essentially a list of command-line interface (CLI) instructions that Docker Engine will run in order to assemble the image.

Docker Image

Docker Image, uygulamanızın altyapısında çalışan gerekli işletim sistemi kütüphanelerinin bulunduğu bir yapıdır. Çalışmaya hazır bir şekilde bekletilen imajlardır. “hub.docker.com” sitesinden imajları kendi lokalimize indirebiliriz ve bu imajdan container oluşturabiliriz. In short, Docker Image is a file that consists of multiple layers and enables container creation. Docker Image is a template.

image

Dockerfile -> Docker Image -> Docker Container

While Docker Image is read-only (Read-Only) templates that we download on “hub.docker.com” site, they are files that can be written and modified on Docker containers.

image

Docker Hub

DockerHub is a repo where created docker images are uploaded and shared. There are two types of repos, public and private. Publicly published images can be seen and used by everyone.

BASIC COMMANDS

Control your images.

docker images

Control your containers

docker container ls 

Control whether container is running properly or not. localhost:8000 go your local host and check if a page exists.

Docker Compose Commands

This command builds images in the docker-compose.yml file. The job of the build command is to get the images ready to create containers, so if a service is using the prebuilt image, it will skip this service.

   docker-compose build

This command will list the images you’ve built using the current docker-compose file.

   docker-compose image

This is similar to the docker run command. It will create containers from images built for the services mentioned in the compose file. web is the name of service.

   docker-compose run web django-admin startproject composeexample .

This command does the work of the docker-compose build and docker-compose run commands. It builds the images if they are not located locally and starts the containers. If images are already built, it will fork the container directly.

   docker-compose up

This command list all the containers in the current docker-compose file. They can then either be running or stopped.

   docker container ps

Read More: Docker Codes