Learn to build and deploy your distributed applications easily to the cloud with Docker
Follow the curriculum on docker-curriculum.com
:dolphin: A comprehensive tutorial on getting started with Docker!
Home Page: https://docker-curriculum.com/
License: MIT License
Learn to build and deploy your distributed applications easily to the cloud with Docker
Follow the curriculum on docker-curriculum.com
The static site demo does not cover this and allows them to remain running. Suggest you include, at the end of the section, how to stop the containers in which the websites are running.
I have been following along with your tutorial, but with docker-compose version 1.7.0 there is no longer the option for --x-networking.
Looking at the docker documentation, there is now a v2 for the compose file. Would suggest updating the tutorial to reflect the newer version of compose.
Need to update the memory size of virtualbox instance to at least 2gb.
Elasticsearch v5 introduces an error "max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]".
This can be fixed by running sysctl -w vm.max_map_count=262144 on your docker machine instance. You can access it through docker-machine ssh.
excellent tutorial.. one stop shop for understanding Docker and start wth..
This is my first time learning and using docker and your tutorial is great. I did have a problem because of the way the tutorial is laid out and your choice of text placement. Under section 2.4 at, "Let's run the following (don't forget the period!) -", you say to use the following command which is in a large pre-tag box and only after that do you specify that we should use our user name instead of yours. I didn't realize that that is how it is being associated with your repo and I can't find a simple way to change the associated user for the image I created. Anyone who already knows what's going on would know already that that is where their user name goes but a newby literally doing exactly as you say in order, like me, is going per line. So, after I created the image and then scrolled down to be able to see the following paragraph, I found out I'm stuck on your repo.
You can upgrade your instructions on flask-app to say if you get permission errors when running
$ pip install -r requirements.txt
and you don't want to sudo creating a global install of requirements.txt then use
$ pip install --user -r requirements.txt
ALSO you may want to tell dummy first timers like me to make sure and open their public port to 5000 if they are using a VPS...
Great curriculum! Any reason you didn't include Kubernetes? It's the most popular container orchestration platform - we're happy to help flesh this out :)
(disclosure, I work on Kubernetes)
Hi!
Thanks for the tutorial. Really enjoyed.
Had a little hick-up with the 'ecs-cli up ...' command, since I didn't get right away that I really need to install and configure the aws tool. But I got it working.
The docker compose ran fine for me locally, but when I ran the 'ecs-cli compose ...' command the es instance stopped with exit code 1.
user@computer:/dev/FoodTrucks$ ecs-cli compose --file aws-compose.yml up/dev/FoodTrucks$ ecs-cli ps
INFO[0000] Using ECS task definition TaskDefinition="ecscompose-FoodTrucks:1"
INFO[0000] Starting container... container="ab4f0282-60d2-45ff-ba07-58050a34c90c/web"
INFO[0000] Starting container... container="ab4f0282-60d2-45ff-ba07-58050a34c90c/es"
INFO[0000] Describe ECS container status container="ab4f0282-60d2-45ff-ba07-58050a34c90c/web" desiredStatus=RUNNING lastStatus=PENDING taskDefinition="ecscompose-FoodTrucks:1"
INFO[0000] Describe ECS container status container="ab4f0282-60d2-45ff-ba07-58050a34c90c/es" desiredStatus=RUNNING lastStatus=PENDING taskDefinition="ecscompose-FoodTrucks:1"
INFO[0012] Describe ECS container status container="ab4f0282-60d2-45ff-ba07-58050a34c90c/web" desiredStatus=RUNNING lastStatus=PENDING taskDefinition="ecscompose-FoodTrucks:1"
INFO[0012] Describe ECS container status container="ab4f0282-60d2-45ff-ba07-58050a34c90c/es" desiredStatus=RUNNING lastStatus=PENDING taskDefinition="ecscompose-FoodTrucks:1"
INFO[0024] Stopped container... container="ab4f0282-60d2-45ff-ba07-58050a34c90c/web" desiredStatus=STOPPED lastStatus=STOPPED taskDefinition="ecscompose-FoodTrucks:1"
INFO[0024] Stopped container... container="ab4f0282-60d2-45ff-ba07-58050a34c90c/es" desiredStatus=STOPPED lastStatus=STOPPED taskDefinition="ecscompose-FoodTrucks:1"
user@computer:
Name State Ports TaskDefinition
ab4f0282-60d2-45ff-ba07-58050a34c90c/web STOPPED ecscompose-FoodTrucks:1
ab4f0282-60d2-45ff-ba07-58050a34c90c/es STOPPED ExitCode: 1 ecscompose-FoodTrucks:1
user@computer:~/dev/FoodTrucks$
I checked my ecs console, but couldn't find any hits why the es instance failed.
Can you give me any hints on how to debug this to find out why it works locally, but fails on AWS?
Thanks heaps,
Marcel
I try to deploy the catnip application, but unfortunately don't see the expected GIFs when I go to the URL for the Environment.
Just see the generic "Congratulations! Your docker container is running in EB".
It am guessing that the Container port 5000 is not mapped to port 80.
Does this need to be specified in Dockerrun.aws.json?
Thank you for a very nice tutorial!
I got a bit confused about the definition of base images, in your tutorial it is written:
An important distinction to be aware of when it comes to images is between base and user images.
But this is different from the definition in the docker glossary:
An image that has no parent is a base image - docker glossary
I think you are confusing official images, (the ones that are collected here) with base images. It seems that some of the official images are base images but not all (for example golang or buildpack-deps).
It is also possible to create your own base images, as shown in this guide.
I suggest the following change:
An important distinction to be aware of when it comes to images is between base and child images.
Then there are two more types of images that can be both base and child images, they are official and user images.
Throughout the majority of the tutorial you appear to assume the reader has not used AWS, but when we get to this line
If you've not configured the AWS CLI on your computer before, you will also need to provide an access key and a secret key.
they are left with minimal instruction as to what an access key is, how they get it, or how to provide it to aws-cli.
Everything you run is inside a container; there doesn't seem to be any need to install Java on the outer machine as you state at the beginning.
Hats off man! I think this should be the defaul tutorial in Docker website. Got the full hang of it in 10 mins.
Following along in the tutorial, I can make it to section 3.2 without trouble, but then I have this problem:
root@ca8044fd4498:/opt/flask-app# curl 172.17.0.2:9200
curl: (7) Failed to connect to 172.17.0.2 port 9200: Connection refused
It does work fine after creating the "foodtrucks" network.
Hello,
I'm running ubuntu and I've done the following:
piyush@fulmar:~$ docker run -d -P --name static-site prakhar1989/static-site
f24c9271a2b66b353c779aba0c52ba088cd39af210e65d66f1e77f0425906863
piyush@fulmar:~$ docker port static-site
443/tcp -> 0.0.0.0:32768
80/tcp -> 0.0.0.0:32769
When I go to http://localhost:32768 I can't see anything, but if I do the following
piyush@fulmar:~$ docker run -p 8888:80 prakhar1989/static-site
Then http://localhost:8888 works. Why is this happening?
Thanks for the great tutorial!
Hi Prakhar,
I was going through your docker tutorial where you suggested to clone the docker-curriculum repo and run the flask app. However, when I ran the command
pip install -r requirements.txt
It did not install the Flask module. I had to manually install it by running
pip install flask
While trying Docker Tutorial https://prakhar.me/docker-curriculum/#dockerrun
getting error while running root@ip-172-31-22-20:~/docker-curriculum# docker build -t ashishkarpe/foodtrucks-web .
root@ip-172-31-22-20:~/docker-curriculum# docker build -t ashishkarpe/foodtrucks-web .
Sending build context to Docker daemon 5.32 MB
Step 1 : FROM ubuntu:14.04
---> 3f755ca42730
Step 2 : MAINTAINER Prakhar Srivastav [email protected]
---> Using cache
---> ca0cf0254114
Step 3 : RUN apt-get -yqq update
---> Using cache
---> 4952fb95a34d
Step 4 : RUN apt-get -yqq install python-pip python-dev
---> Using cache
---> 73bd849c6164
Step 5 : RUN apt-get -yqq install nodejs npm
---> Using cache
---> c48d602eccda
Step 6 : RUN ln -s /usr/bin/nodejs /usr/bin/node
---> Using cache
---> 221206c99a7f
Step 7 : ADD flask-app /opt/flask-app
---> Using cache
---> 7ddfac0cdf0e
Step 8 : WORKDIR /opt/flask-app
---> Using cache
---> 451217e08677
Step 9 : RUN npm install
---> Running in 547c36e97297
npm ERR! install Couldn't read dependencies
npm ERR! Error: ENOENT, open '/opt/flask-app/package.json'
npm ERR! If you need help, you may report this log at:
npm ERR! http://github.com/isaacs/npm/issues
npm ERR! or email it to:
npm ERR! [email protected]
npm ERR! System Linux 3.13.0-92-generic
npm ERR! command "/usr/bin/nodejs" "/usr/bin/npm" "install"
npm ERR! cwd /opt/flask-app
npm ERR! node -v v0.10.25
npm ERR! npm -v 1.3.10
npm ERR! path /opt/flask-app/package.json
npm ERR! code ENOENT
npm ERR! errno 34
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /opt/flask-app/npm-debug.log
npm ERR! not ok code 0
After starting the es with new network, I ran the flaskapp with bash on the new network.
When I open /etc/hosts file i donot se the IPs for ES updated here. However the app is working fine, accessible as expected
Can we get away even if Hosts file is not updated with the container-host/ip values?
I get an error when attempting to launch the flask app. It could have something to do with the way my Python is configured, but I wanted to see if anyone else was running into this problem, or had a clean way to resolve it. I am not too familiar with Python/Flask.
Python path for default (non-homebrew version). My assumption is that I have a pathing issue.
When executing whereis python
/usr/bin/python
Python version
Python 2.7.10
Thanks for such great content! π
It's possible I did the setup wrong but I thought it would be useful to add a note before the docker push
section to run docker login
if you get unauthorized: access to the requested resource is not authorized
absolutely love the tutorial, thanks!
description
author
Hi Prakhar,
Thanks for the awesome tutorial. i some one issue here. after running python.py I am getting
but when i am hitting url on local i am getting 0.0.0.0 refused to connect.
For some reason after I run the docker run -p 8888:5000 <user_name>/catnip
(although I get the message that the site is running on http://0.0.0.0:5000/) I don't seem to be able to access the address.
When I click on the link I get: This site canβt be reached 0.0.0.0 refused to connect.
It is different now, uploading the code is done in the very first screen of env. creation and has a tip "ZIP or WAR". Form your tutorial it is unclear what is to be uploaded here. Is it the json file?
I'm stuck in the part:
The next step enables the CLI to create a CloudFormation template.
$ ecs-cli up --keypair ecs --capability-iam --size 2 --instance-type t2.micro
In tutorial the output expected to be:
INFO[0000] Created cluster cluster=foodtrucks
INFO[0001] Waiting for your cluster resources to be created
INFO[0001] Cloudformation stack status stackStatus=CREATE_IN_PROGRESS
INFO[0061] Cloudformation stack status stackStatus=CREATE_IN_PROGRESS
INFO[0122] Cloudformation stack status stackStatus=CREATE_IN_PROGRESS
INFO[0182] Cloudformation stack status stackStatus=CREATE_IN_PROGRESS
INFO[0242] Cloudformation stack status stackStatus=CREATE_IN_PROGRESS`
but on my mac, it is:
ERRO[0040] Failed to Create Cluster
cluster=foodtrucks error="NoCredentialProviders: no valid providers in chain. Deprecated. \n\t
For verbose messaging see aws.Config.CredentialsChainVerboseErrors"
ERRO[0040] Error executing 'up': NoCredentialProviders: no valid providers in chain. Deprecated.
For verbose messaging see aws.Config.CredentialsChainVerboseErrors
any idea what's going wrong? btw, great tutorial!
Hi,
I went through tutorial with Docker version 1.11.00
. In section 3.2 Docker Network we creating new container with --net=foodtrucks
and then examining /etc/hosts
to make sure that appropriate name resolutions are added to the hosts
file:
$ docker run -it --rm --net foodtrucks prakhar1989/foodtrucks-web bash
root@53af252b771a:/opt/flask-app# cat /etc/hosts
172.18.0.3 53af252b771a
127.0.0.1 localhost
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
172.18.0.2 es
172.18.0.2 es.foodtrucks
However, in newer versions of Docker name resolution is done using DNS. So, there will be no additional entries in the hosts
file. Instead, DNS server IP will be added to /etc/resolv.conf
:
root@56148395930d:/opt/flask-app# cat /etc/resolv.conf
search synapse.com
nameserver 127.0.0.11
options ndots:0
To make sure this works:
root@56148395930d:/opt/flask-app# ping es
PING es (172.18.0.2) 56(84) bytes of data.
64 bytes from es.foodtrucks (172.18.0.2): icmp_seq=1 ttl=64 time=0.092 ms
64 bytes from es.foodtrucks (172.18.0.2): icmp_seq=2 ttl=64 time=0.122 ms
64 bytes from es.foodtrucks (172.18.0.2): icmp_seq=3 ttl=64 time=0.117 ms
64 bytes from es.foodtrucks (172.18.0.2): icmp_seq=4 ttl=64 time=0.122 ms
^C
--- es ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3005ms
rtt min/avg/max/mdev = 0.092/0.113/0.122/0.014 ms
After the foodtrucks bridge is created, and the elasticsearch and foodtrucks-web are launched with --net foodtrucks, the foodtrucks-web's /etc/hosts does not contain an entry for the es host. Despite that, connections to the es host from foodtrucks-web do work. I am not sure how, but they do. Does docker daemon take care of this?
Not really sure what to do about this. Using OSX.
The tutorial is great but the section 2.5 Docker on AWS
needs to be updated as AWS changed the setup options and most of this sections would need rewriting.
Here you specify that the catnip image should be run as so:
$ docker run -p 5000:5000 prakhar1989/catnip
But here you write the same expression like this:
$ docker run -p 8888:5000 prakhar1989/catnip
Is there a reason for these inconsistencies? I was confused why connecting to port 5000 on localhost didn't work while following the tutorial in the second link, but eventually figured out that I could connect to port 8888.
Under 1.2 / Docker Daemon: s/operation system/operating system/
Can you describe how foodtrucks can update? deploy (on ECS) new features, etc.
How this workflow can be?
Only the map of SF gets displayed. I found one issue with the app.py: on line 39, load_data_in_es() gets called if safe_check_index() fails instead of when it succeeds. After fixing it, the app now does print "loading data in elasticsearch", and the number of trucks it loaded, but the webpage still doesn't display any trucks, and I'm out of ideas. From within the foodtrucks-web image, curl test to es works fine.
Hey Prakhar,
On the page: http://prakhar.me/docker-curriculum/ the picture under section 3.1 SF Food Trucks is not appearing. Put the absolute URL :)
Cheers!
Pascal
View Indices
curl 0.0.0.0:9200/_cat/indices?v
Health
curl 0.0.0.0:9200/_cat/health?v
Search
curl 0.0.0.0:9200/sfdata/_search?q=*&burger
In the tutorial shortly after the instruction to run docker run -it busybox sh it says:
Once everything stops working, you can exit the container
But it doesn't tell you how to do that! (Its ctrl+p followed by ctrl+q)
Changes are no longer made in /etc/hosts
. Update this section to reflect the last stable version.
First thank you for this tutorial!
When I run the python command on my computer from your cloned version it works great, but when I attempt to make my own Dockerfile and then run that version my website never comes up even though it shows to have built successfully.
Any suggestions? Additionally the instructions here are somewhat confusing
"The application directory does contain a Dockerfile but since we're doing this for the first time, we'll create one from scratch. To start, create a new blank file in our favorite text-editor and save it in the same folder as the flask app by the name of Dockerfile."
how to create another Dockerfile apart from the one in use?
~]# docker run prabhakar1989/static-site
Unable to find image 'prabhakar1989/static-site:latest' locally
Pulling repository docker.io/prabhakar1989/static-site
docker: Error: image prabhakar1989/static-site:latest not found.
See 'docker run --help'.
[root@0centos2 ~]# docker pull prabhakar1989/static-site
Using default tag: latest
Pulling repository docker.io/prabhakar1989/static-site
Error: image prabhakar1989/static-site:latest not found
Hi, I am working on the user-defined network and after I run this command:
$ docker run -it --rm --net foodtrucks prakhar1989/foodtrucks-web bash
/etc/hosts file is like this:
127.0.0.1 localhost
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
172.18.0.3 5c76db6f18d1
The strange thing is that curl es:9200
works fine and after run:
docker run -d --net foodtrucks -p 5000:5000 --name foodtrucks-web prakhar1989/foodtrucks-web
I can visit the app. So except the "/etc/hosts" file, everything works fine.
Why this happened? Thank you very much.
First of all: a very well built up and well written tutorial. Kudo's and compliments to you. Even new things like docker networking were integrated.
Since linking the containers without networking is easy enough, the networking part is not strictly necessary. I therefore expected that you would have used the networking part in the docker-compose file also, but you didn't. I think it would be great if you mention the (upcoming) networking support (https://docs.docker.com/compose/networking/) and also explain the subtle difference between the link
instruction in docker-compose and the --network
you use in the networking example. Or as alternative, explain linking your containers by hand, enhancing that using networking and then go on to docker-compose (which still has the challenge in service discovery based on the generated names for containers :-) )
Anyway, again, lot's of respect for your great tutorial, I'm bookmarking it as reference to give to colleagues who want to learn more about Docker!
Is misspelled as pooco ( an adware malware fakeware scamware site) instead of pocoo
If i wasn't on mobile I would have done a PR
Thanks for doing this! It's a great start.
As of Docker 1.10, we got the ability to NOT run as root in the container. This is a good thing for any number of reasons (security, etc.) so it should really be covered in any tutorial. At least the "If you're feeling particularly adventurous you can try rm -rf bin in the container" won't work any more.
Hi, Thanks for the tutorial document.
I was able to follow it till para 2.4 .
During build I get below error
light@light-OptiPlex-7010:~/docker-curriculum/flask-app$ docker build -t imlight/lightimagerepo .
Sending build context to Docker daemon 8.704 kB
Step 1 : FROM python:3-onbuild
Executing 3 build triggers...
Step 1 : COPY requirements.txt /usr/src/app/
---> Using cache
Step 1 : RUN pip install --no-cache-dir -r requirements.txt
---> Running in 6442f9922bcc
Collecting Flask==0.10.1 (from -r requirements.txt (line 1))
Retrying (Retry(total=4, connect=None, read=None, redirect=None)) after connection broken by 'NewConnectionError('<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7f715d12b4e0>: Failed to establish a new connection: [Errno -2] Name or service not known',)': /simple/flask/
I didnt had any issue till just before this.
I believe this has something to do with http proxy , but i have these variables shared in environment
echo $http_proxy && echo $https_proxy
http://XXXXXXXX:8080/
https://XXXXXXXX:8080/
Created new image using the docker file
FROM python:3-onbuild
EXPOSE 5000
CMD ["python", "./app.py"]
On running the docker build command:
docker build -t padmam/catnip .
Sending build context to Docker daemon 9.728 kB
Step 1 : FROM python:3-onbuild
Step 1 : COPY requirements.txt /usr/src/app/
Step 1 : RUN pip install --no-cache-dir -r requirements.txt
---> Running in 8f79fbfa9142
Collecting Flask==0.10.1 (from -r requirements.txt (line 1))
Downloading Flask-0.10.1.tar.gz (544kB)
Collecting Werkzeug>=0.7 (from Flask==0.10.1->-r requirements.txt (line 1))
Downloading Werkzeug-0.11.11-py2.py3-none-any.whl (306kB)
Collecting Jinja2>=2.4 (from Flask==0.10.1->-r requirements.txt (line 1))
Downloading Jinja2-2.8-py2.py3-none-any.whl (263kB)
Collecting itsdangerous>=0.21 (from Flask==0.10.1->-r requirements.txt (line 1))
Downloading itsdangerous-0.24.tar.gz (46kB)
Collecting MarkupSafe (from Jinja2>=2.4->Flask==0.10.1->-r requirements.txt (line 1))
Downloading MarkupSafe-0.23.tar.gz
Installing collected packages: Werkzeug, MarkupSafe, Jinja2, itsdangerous, Flask
Running setup.py install for MarkupSafe: started
Running setup.py install for MarkupSafe: finished with status 'done'
Running setup.py install for itsdangerous: started
Running setup.py install for itsdangerous: finished with status 'done'
Running setup.py install for Flask: started
Running setup.py install for Flask: finished with status 'done'
Successfully installed Flask-0.10.1 Jinja2-2.8 MarkupSafe-0.23 Werkzeug-0.11.11 itsdangerous-0.24
Step 1 : COPY . /usr/src/app
---> 6e8479e772e6
Removing intermediate container 717042c9f287
Removing intermediate container 8f79fbfa9142
Removing intermediate container 771643994a90
Step 2 : EXPOSE 5000
---> Running in 1969f777615b
---> 115cb97280da
Removing intermediate container 1969f777615b
Step 3 : CMD python ./app.py
---> Running in d713dd80bd16
---> b9f31a612334
Removing intermediate container d713dd80bd16
Successfully built b9f31a612334
And then running the image:
docker run -p 8888:5000 padmam/catnip
The http://0.0.0.0:5000/ wont launch the cat gif. How can i check what went wrong?
End of section "1.1 Docker Run":
$ docker run -rm busybox echo hello world
unknown shorthand flag: 'r' in -rm
The correct parameter is --rm
two dashes.
I tried running the command as per the tutorial, but got this error:
$ docker build -t flux627/catnip .
Sending build context to Docker daemon 8.704 kB
Step 1 : FROM python:3-onbuild
Pulling repository docker.io/library/python
Tag 3-onbuild not found in repository docker.io/library/python
Any suggestions?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.