├── Dockerfile ├── Dockers.pdf ├── README.md ├── app.py └── requirements.txt /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:16.04 2 | 3 | RUN apt-get update -y && \ 4 | apt-get install -y python-pip python-dev 5 | 6 | # We copy just the requirements.txt first to leverage Docker cache 7 | COPY ./requirements.txt /app/requirements.txt 8 | 9 | WORKDIR /app 10 | 11 | RUN pip install -r requirements.txt 12 | 13 | COPY . /app 14 | 15 | ENTRYPOINT [ "python" ] 16 | 17 | CMD [ "app.py" ] 18 | -------------------------------------------------------------------------------- /Dockers.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mostafa-wael/Docker-Guide-for-Beginners/0d97bee3065c510e9e5380b399d074c990caac3d/Dockers.pdf -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Open Presentation Materials 2 | [![Slides](https://user-images.githubusercontent.com/56788883/140322800-a4cf9607-9d97-4291-8071-c0b381321fef.png)][1] 3 | 4 | [1]: ./Dockers.pdf 5 | 6 | 7 | # Install Docker and Docker compose on your machine 8 | - [Install Docker](https://docs.docker.com/engine/install/) 9 | - [Install Docker-compose](https://docs.docker.com/compose/install/) 10 | 11 | # Docker Commands Examples 12 | [Docker Playground](https://labs.play-with-docker.com/) 13 | 14 | 1. run hello world: `docker run hello-world` 15 | 2. complex image: `docker run -it danielkraic/asciiquarium` 16 | 3. get images: `docker images` 17 | 4. list containers: `docker ps`, `docker ps -a`, `docker container ls` 18 | 5. container runs and close: `docker run ubuntu`, `docker run ubuntu echo hi` 19 | 6. check for it in the images: `docker images` 20 | 7. previously run containers: `docker ps -a` 21 | --- 22 | 8. keep running: `docker run ubuntu sleep 5` 23 | 9. run in interactive mode: `docker run -it ubuntu` 24 | --- 25 | 10. get a new image: `docker pull kodekloud/simple-webapp` 26 | 11. run the image: `docker run kodekloud/simple-webapp` 27 | 12. Hide logs(detached mode): `docker run -d kodekloud/simple-webapp` 28 | 13. check it: `docker ps` 29 | 14. attach the container to see logs(no logs?): `docker attach ` 30 | 15. get the logs: `docker logs ` 31 | --- 32 | 16. detach ubuntu: `docker run -d -it ubuntu` 33 | 17. exec ubuntu: `docker exec b2 echo hi` 34 | --- 35 | 18. inspect: `docker inspect ` 36 | 19. remove the container: `docker rm ` 37 | --- 38 | 20. map ports: `docker run -p 80:8080 kodekloud/simple-webapp` 39 | 21. get networks: `docker network ls` 40 | --- 41 | 22. view build history of an image: `docker history kodekloud/simple-webapp` 42 | 43 | # Useful Notes: 44 | 45 | - If you encountered this error 46 | >Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get "http://%2Fvar%2Frun%2Fdocker.sock/v1.24/images/json": dial unix /var/run/docker.sock: connect: permission denied 47 | 48 | Just type: `sudo chmod 666 /var/run/docker.sock` 49 | 50 | -------------------------------------------------------------------------------- /app.py: -------------------------------------------------------------------------------- 1 | # flask_web/app.py 2 | # to build --> docker build -t . 3 | # to run --> docker run -p 5000:5000 4 | 5 | From flask import Flask 6 | app = Flask(__name__) 7 | 8 | @app.route('/') 9 | def hello_world(): 10 | return 'Hey, we have Flask in a Docker container!' 11 | 12 | 13 | if __name__ == '__main__': 14 | app.run(debug=True, host='0.0.0.0') 15 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | Flask==0.10.1 2 | --------------------------------------------------------------------------------