Coder Social home page Coder Social logo

ct83 / ubuntu-docker-compose-starter-pack Goto Github PK

View Code? Open in Web Editor NEW
9.0 2.0 4.0 4 KB

Starter pack to help creating Ubuntu Containers using Docker and Docker Compose easier. 🐳

License: BSD 2-Clause "Simplified" License

Dockerfile 66.30% Shell 33.70%
docker ubuntu-container starter-kit starter-template docker-compose docker-compose-template

ubuntu-docker-compose-starter-pack's Introduction

Ubuntu-Docker-Compose-Starter-Pack

Recently, I was trying to spin up a simple Ubuntu container. I noticed that a simple guide with some basic boilerplate code was too difficult to find. So, I wrote my own.

View it on Github - Ubuntu-Docker-Compose-Starter-Pack

🐳 

Note, this assumes that you have a gentle grasp of what Docker Compose and Containerization are, so stay put for the rodeo!

Components

  1. Dockerfile
  2. Docker Compose Configuration
  3. Startup script

1. Dockerfile

Consider this a recipe that tells Docker how the image needs to be assembled.

Read More - Here

FROM ubuntu:latest

COPY . ./start_script.sh
RUN ["chmod", "+x", "start_script.sh"]

ENTRYPOINT ["sh","./start_script.sh"]

Here, we pull the latest ubuntu image from Docker Hub and copy over the startup script (and make it executable) which will be run when the container is initialized, more on this later.

2. Docker Compose Configuration

A Docker Compose Configuration file or .yml file tells docker how many and what containers we are trying to spin up, what volumes need to be mounted and what environment variables need to be defined.

Read More - Here

version: "3.3"

services:
  hello_container:
    container_name: hello_contaier
    build: .

    volumes:
      - ./data:/mnt/data
      - ./data2:/mnt/data2

    environment:
      SYS_NAME: good-container

volumes: 
  data :
  data2 :

Here, we are declaring the container which we plan to use, it's name, volumes which we plan to mount and environment variables we want to use.

3. Startup Script

This is the file that will be run when the container is created, all the commands your servers, startup scripts should go in here.

#!/bin/bash

echo "Hello World! This is the Ubuntu Container!"

That's it!

Spinning up the containers

Once you have docker and docker-compose installed you can simply do

docker-compose up --build

to start everything!

View it on Github - Ubuntu-Docker-Compose-Starter-Pack

ubuntu-docker-compose-starter-pack's People

Contributors

ct83 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  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.