Docker Tutorial

Photography of Ship

THE IMPORTANCE OF DOCKER
A Docker repository allows one to share container images and run applications with a team. It allows applications to use the same Linux kernel as the system that they're running on.

How to Create a Docker Repository:
Note: Docker Desktop needs to be open in order to make a repository.
  1. Sign into the Docker Hub website.
  2. Click on Repositories .
  3. Click on Create Repository.
  4. After clicking Create , you can now start using the command docker push to push images to the repository.
How to Store an Image with your Own Website Stored in it and Served Using Apache:
Note: Docker Desktop MUST be open to do this.
  1. Open a Command terminal on your computer/laptop.
  2. Pull an Ubuntu image from the Docker Hub.
  3. Command to use: docker pull ubuntu
  4. Run image to start the container.
  5. Command to use: docker run -it ubuntu:/latest /bin/bash
  6. Install correct applications in the docker container and save.
  7. Commands to use:
    1. apt-get update
    2. apt-get install apache2
    3. apt-get install vim
    4. exit
  8. Commit container to create a new Docker image.
  9. Command to use: docker ps -a
  10. Check container ID and change name to new Docker image.
  11. Command to use: docker commit <Container ID > <new name >
  12. Share the directory between Docker and host. Note: The directory MUST exist before sharing.
  13. Commands to use: docker run -it -v /local_directory_name:/directory_name_in_docker container_name /bin/bash
  14. Use vi to make and edit an index.html file in the shared directory.
  15. Commands to use:
    1. pwd
    2. cd /var/www/html
  16. Host website and start apache service.
  17. Command to use: /etc/init.d/apache2 restart