Learn how to use Docker and troubleshoot common issues with this Docker tutorial for beginners.
In this video, I cover essential Docker commands and provide Docker troubleshooting tips to fix problems quickly. Get started with Docker Desktop and understand Docker container basics.
========================================
The commands explained in the video are:
Pull image
`docker pull postgres`
Run container (local demo)
```
docker run --name my_postgres \
-e POSTGRES_PASSWORD=mysecretpassword \
-p 5432:5432 -d postgres
```
Connect (psql inside the container)
`docker exec -it my_postgres psql -U postgres`
Or enter bash/shell, then psql
```
docker exec -it my_postgres bash
docker exec -it my_postgres sh
```
Then, inside the container
`psql -U postgres`
Fresh start
`docker stop my_postgres && docker rm my_postgres`
========================================
A couple of troubleshooting points were mentioned in the video. When running containers, you may experience a couple of issues. Here are a few ways to fix them:
Possible Error 1: If you have PostgreSQL running locally on the 5432 port, this port will not be available for a docker container.
Solution: Change the local host port to, e.g., 5431, so the connection will look like "-p 5431:5432"
Possible Error 2: If you have a container with a given name, you will not be able to create another container with the same name.
Solution: Simply change the container name, e.g., "my_postgres" to "my_postgres_2" or a more meaningful name if you want.
Possible Error 3: A typo in a "docker run" command, especially an environment variable, such as POSTGRESS_PASSWORD instead of the POSTGRES_PASSWORD, preventing the container from running.
Solution: Double-check the spelling of each part of the command. Stop the running container, remove it, and re-run the corrected "docker run" command.
========================================
Timestamps for those who are in a hurry:
00:50 What to Expect?
01:28 Docker Installation
01:56 Pull postgres Image
02:20 Image VS. Container (Docker)
02:39 Run Container
03:46 Connect to DB in 4 alternatives
05:56 psql commands
06:28 Need a Fresh Start?
========================================
What to watch next:
A SQL playlist:
• Machine Learning in SQL? But I Am Python E...
6 Practical SQL Style Guidelines | Google BigQuery | Tips and Tricks
• 6 Practical SQL Style Guidelines | Google ...
PostgreSQL Stored Procedures
• PostgreSQL Stored Procedures EXPLAINED | S...
SQL Procedures Automation. (Triggers)
• SQL Automation | PostgreSQL Triggers EXPLA...
Relational Database EXPLAINED | PostgreSQL Step-by-Step From Scratch
• Relational Database EXPLAINED | PostgreSQL...
========================================
Ways to connect:
Subscribe!
https://bit.ly/RBrilenkovYT
LinkedIn
/ ruslan-brilenkov
Medium
/ ruslan-brilenkov
========================================
If you are interested in generating royalty-free background music with AI software, check out the Mix.audio tool. It can potentially save you a lot of time. Use the promo link below to get a 30% discount on your first monthly subscription payment, and by doing so, you will also support the channel at no extra cost to you:
https://bit.ly/ruslanpromoAI
========================================
Disclaimer: Everything presented in this video is my own opinion and is intended to educate and share information. Nothing mentioned or described here constitutes legal or financial advice. Ruslan Brilenkov is not responsible for any profits or losses associated with your investment. So, please be responsible for your own actions.