Skip to content

makcientista/Docker_Introduction

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Docker Demonstrations with DSA

This repository demonstrates various use cases for Docker, including running a web server, creating a database, building custom Docker images, and using Docker Compose for managing services.


1. Requirements

Ensure you have the following installed:

  • Docker
  • Docker Compose

2. Running a Web Server

Run an Nginx web server on port 8080 using Docker:

  1. Creating a Custom Database Set up a PostgreSQL database with custom configurations:
  • $ docker run --name database -p 5435:5432 -e POSTGRES_USER=dsa -e POSTGRES_PASSWORD=dsa1010 -e POSTGRES_DB=dsadb -d postgres:16.0

Parameters:

  • POSTGRES_USER: Sets the database username (dsa).
  • POSTGRES_PASSWORD: Sets the database password (dsa1010).
  • POSTGRES_DB: Creates a database named dsadb. Access the database at localhost:5435.
  1. Building a Custom Docker Image 4.1. Create a Dockerfile Create a file named Dockerfile with the following content: > Screenshot from 2024-11-29 14-21-24

4.2. Create a Python Script and save the file named testedsa.py with the following content: print("Olá, Bem-Vindo(a) ao Docker com a DSA!")

4.3. Build the Docker Image Run the following command to build the image: $ docker build -t dsa-image .

  • Output:

Screenshot from 2024-11-29 14-25-10

  1. Using Docker Compose 5.1. Create a Docker Compose File Create a file named docker-compose.yml with the following content:

Screenshot from 2024-11-29 14-19-50

5.2. Run Docker Compose Commands

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published