Skip to content

Latest commit

 

History

History
45 lines (23 loc) · 1.53 KB

Docker.md

File metadata and controls

45 lines (23 loc) · 1.53 KB

Running Bash into docker container

docker exec -it <ContainerName/ContainerID> bash

Copy File into Docker Container

docker cp <file-path> <ContainerName>:<destinationPath>

Docker Postgres Setup

  1. Open cmd and pull the docker postgres image using command : docker pull postgres

  2. Wait for it download

  3. Run the container using command : docker run --name postgresContainer -e POSTGRES_PASSWORD=123 -d -p 5432:5432 postgres

  4. Verify if the container is running using command : docker ps

  5. You can execute psql commands using command : docker exec -it postgresContainer psql -U postgres

Where ContainerID is the ID you obtain from docker ps command

  1. Once psql opens, use this command to create a test database : create DATABASE test_db;

  2. More docker resources : https://hub.docker.com/_/postgres/

Docker MySQL Setup

  1. Open cmd and pull the docker postgres image using command : docker pull mysql

  2. Wait for it download

  3. Run the container using command : docker run --name mysqlContainer -e MYSQL_ROOT_PASSWORD=123 -d -p 3306:3306 mysql

  4. Verify if the container is running using command : docker ps

  5. You can execute psql commands using command : docker exec -it mysqlContainer mysql --user=root --password

Where ContainerID is the ID you obtain from docker ps command

  1. Enter the password.

  2. Once mysql opens, use this command to create a test database : create DATABASE test_db;

  3. More docker resources : https://hub.docker.com/_/mysql/