GithubHelp home page GithubHelp logo

do-cdmx-nginx's Introduction

Instructions for the Docker from scratch workshop

If you are new to Digital Ocean use this referral link to get a $10 USD credit. Sign Up

Basic Docker Commands:

  • docker run
  • docker start <name|id>
  • docker stop <name|id>
  • docker ps [-a include stopped containers]
  • docker rm <name|id>

Connect to the droplet

ssh root@[hostname]

Login to your Docker account

docker login

Check that the installation is working with the official hello-world container

docker run hello-world

Run a web-based hello world

docker run tutum/hello-world

To expose the container to the world

docker run -p 80:80 tutum/hello-world

At this point if you run 'docker ps -a' you will see 3 or more containers, which are either stopped or running. To get rid of them we execute:

docker rm [containerId]

You can specify only the start of the containerId and this command will work. I.e. ('docker rm e8' for container with Id of e8f1c0192dd8)

Let's create a couple of containers now

docker run -d --name app1 -p 80:80 tutum/hello-world
docker run -d --name app2 -p 81:80 tutum/hello-world
docker run -d --name app3 -p 82:80 tutum/hello-world

The -d flag runs the container on the background The --name is self-explanatory

We can now run commands using the container's name

docker stop app1
docker start app1

To stop all containers at once we can use this command

docker stop $(docker ps -a -q)

The -a lists all containers, and the -q lists only their id's

Let's now run an nginx server

docker run -d -p 80:80 nginx

Let's get inside our new container using bash

docker exec -i -t [containerId] /bin/bash

The html folder is located at '/usr/share/nginx/html'

To create our first image/container follow these steps on your local machine

Position your terminal on the root of this project, then run

docker build -t [username]/[imageName] .

The . is because we are pulling from this projects root

Then we can run our new instance by doing

docker run -d -p 80:80 [username]/[imageName]

At this point, you want to create a new repository in your DockerHub account Once you've done that, you can push to that repo

docker push pablovilla83/do-cdmx-nginx

Your repo might show that there hasn't been any push. This is an open bug. docker/hub-feedback#301 If you got a digest as confirmation of your push, your up and ready to go.

#Switch back to your digital ocean droplet

docker run -d -p 80:80 [username]/[imageName]

do-cdmx-nginx's People

Contributors

pablovilla83 avatar

Stargazers

Alejandro Maguey avatar

Watchers

James Cloos 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.