Use docker as your virtual environment for your project testing.

What is Docker?

Before we go into the world of Docker, we should know the concept of “container” first.

Container

A container is a standard unit of software that packages up code and all its dependencies so the application runs quickly and reliably from one computing environment to another. A Docker container image is a lightweight, standalone, executable package of software that includes everything needed to run an application: code, runtime, system tools, system libraries and settings.

You can find more in the website shown above in title Container.

What can Docker do?

Docker is a tool designed to make it easier to create, deploy, and run applications by using containers. Containers allow a developer to package up an application with all of the parts it needs, such as libraries and other dependencies, and deploy it as one package.

Install Docker

This can be easily installed following the instructions given by docker website.

Docker usage

Your first ‘Hello world’ through Docker

  • Run docker.

  • Run command docker run ubuntu:18.04 /bin/echo "Hello world" in terminal. If there’s no image in your computer, docker will download one in Docker Hub.

Communicate with Docker through command line

  • Run command docker run -i -t ubuntu:18.04 /bin/bash
  • Enjoy, and you can run exit or CTRL+D to exit your container.

Run docker on background

  • docker run -d ubuntu:18.04 yourcommand

  • Stop: docker stop
  • Use docker ps to check your container status.

Categories:

Updated: