About Docker
Docker is a open source solution that is based container management service. The main purpose of docker is to increase the productivity of developers and dev-ops with less error pron. Docker provides a robust client server app architecture with a strong server, REST API and command line interface client. We can follow the same steps to run more containers and utilize fewer resources.
Docker installation on ubuntu
Open a terminal window and type to update repositories:-> sudo apt-get update
Uninstall Old Versions of Docker if exist:-> sudo apt-get remove docker docker-engine docker.io
To install Docker on Ubuntu, please follow:-> sudo apt install docker.io
Start and Automate Docker:-
> sudo systemctl start docker> sudo systemctl enable docker
Check docker version:-> docker --version
Setup Postgres Image and container:-
Firstly we need to pull postgres image on our local machine from docker hub. To do that simply we need to run this command:-> docker pull postgres
To check all exist docker images:-> docker images
Start postgres instance:-> docker run --name postgres-0 -e POSTGRES_PASSWORD=mypassword -p 5433:5433 -d postgres
Now we can check docker all running container by this command:-> docker ps
Connect and run queries:-> docker exec -it postgres-0 psql -U postgres
Create database:-> CREATE DATABASE ps_database_1
Connect with database:-> /c ps_database_1
Create table:-> CREATE TABLE table_1(something int);
> INSERT INTO table_1 (something) VALUES (1);
Some useful commands for docker
To check docker version:-> docker --version
To download docker image:-> docker pull image_name
To list of all exist images on your machine:-> docker images
To run docker image:-> docker run -it -d image_name
To check what is running in docker:-> docker ps
To list all docker running /exist/stopped with container info:-> docker ps -a
To access docker container:-> docker exec -it container_id bash
To remove docker container:-> docker rm container_id
To remove image:-> docker rmi image_id
To restart docker:-> docker restart container_id
To stop docker container:-> docker stop container_id
Muchas gracias. ?Como puedo iniciar sesion?
Hmm it seems like your website ate my first comment (it was super long) so
I guess I’ll just sum it up what I submitted and say,
I’m thoroughly enjoying your blog. I as well am an aspiring blog
writer but I’m still new to the whole thing. Do you
have any tips for beginner blog writers? I’d genuinely appreciate it.