Sunteți pe pagina 1din 7

Docker And Containers

UE17CS352
Hands-on Session-2
Install Docker, Docker Compose

● Install docker from here


● There are different docker installation methods for each linux distro and you have to
install “docker for desktop” for Mac/Windows
● Recommended to use only linux, as there are multiple issues with docker on
Windows.
● If you do not have native linux, use a VirtualBox.
● Verify that docker is installed by running “sudo docker run hello-world”
Build your DockerFile (Docker Image)

Dockerfile =[docker build]=> Docker image =[docker run]=> Docker container

Documentation: https://docs.docker.com/engine/reference/builder/

https://docs.docker.com/engine/reference/commandline/run/

● docker build /path/to/a/Dockerfile


Basic docker commands
$ docker container ls
$ docker container stop container_name
$ docker container ls -a
$ docker container rm container_name
$ docker image ls
$ docker image rm container_name

Use the provided Dockerfile to build the container.

Extension

● Try to ssh into your docker container and try to execute shell commands.
Docker Compose

● Used for running multi-container Docker applications


● You write one YAML file, which you can then run to be used to deploy your
application easily
● Your application environment is defined by Dockerfile, this can be used for
portability and reproducibility
● You can build your own docker images or pull existing images
● Services for your application are defined by Docker compose
Build and Run your Docker Application With
Docker Compose

Documentation : https://docs.docker.com/compose/

● Create a docker-compose.yml file with the required specifications.


● Run “docker-compose up” to start all the containers.
● Ensure your app is running, by sending a request.

Extension:

● Create a volume, and ensure all the data in your project’s root directory are
stored persistently.
● Port mapping with different ports to the public IP can be routed to different
container ports
Docker Resources
● Docker overview
○ https://docs.docker.com/engine/docker-overview/
● Install Docker on your Ubuntu AWS instance
○ https://docs.docker.com/install/linux/docker-ce/ubuntu/#install-docker-ce
● How to build your own docker image
○ https://docs.docker.com/get-started/part2/
● Map container port to localhost of AWS instance
○ https://docs.docker.com/get-started/part2/#run-the-app
● Publish image to Docker Hub
○ https://hackernoon.com/publish-your-docker-image-to-docker-hub-10b826793faf
● Alpine docker image
○ https://hub.docker.com/_/alpine
● Docker Compose
○ https://docs.docker.com/compose/

S-ar putea să vă placă și