Git Product home page Git Product logo

docker_101's Introduction

This repository contains a simple example of how to use Docker to create a website that uses a database and an API. It was based on the Docker em 22 minutos - teoria e prática video from Ayrton Teshima - Programador a Bordo channel.

Table of contents

Useful Docker commands

Create images

  docker build -t <image_name> .

List images

  docker images

Create containers

  docker run -d -v <absolute_path_to_file>:<container_path> --link another-container-name -p <host_port>:<container_port> --name <container_name> <image_name>

List containers

  docker ps

Access containers

  docker exec -it <container_name> bash

Stop containers

  docker stop <container_name>

Important parameters

  • -d = detached mode (run in background, not blocking terminal)
  • -f = file (dockerfile path)
  • -t = tag (name of the image)
  • -i = interactive mode (keep STDIN open even if not attached)
  • -it = interactive mode + allocate a pseudo-TTY (terminal)
  • -p = port (host_port:container_port)
  • -v = volume (host_path:container_path)
  • --link = link containers (container_name:alias)
  • --name = name of the container
  • --rm = remove container after stop

Windows vs Linux

  • Windows

    • %cd% = current path
    • \ = folder separator
  • Linux

    • $(pwd) = current path
    • / = folder separator

Project specific observations

  • Go through the README.md files in the project folders in this order:

      1. api/db
      1. api
      1. website
  • The order is important because the containers are linked and the database must be up and running before the api container starts

  • The website container is not linked to any other container, so it can be started at any time

  • The api container is linked to the database container, so it must be started after the database container

docker_101's People

Contributors

felipefreitassilva avatar

Watchers

Kostas Georgiou avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.