Install docker
sudo apt install docker.io
Basic commands
- Check Current running container
docker ps - Shows all containers
docker ps -a - Stop container
docker stop container-id - Check Docker version
docker --version - Pull docker image docker hub
docker pull mysql:latest-d - daemon run on background
-e - environment variable
3306:3306 mysql default port
Create a new container/ instance with an image
MySQL
sudo docker run --name mysql -d -e MYSQL_ROOT_PASSWORD=password -p 3306:3306 mysql:latest
# Run on different port
sudo docker run --name mysqlDocker -d -e MYSQL_ROOT_PASSWORD=password -p 3000:3306 mysql:latest
# Command client
sudo docker exec -it db /bin/bash
mysql -u root -ppassword
MariaDB
Connect to mariadb
PostgreSQL
docker run --name postgres12 -p 5432:5432 -e POSTGRES_USER=root -e POSTGRES_PASSWORD=password -d postgres:12-alpine
Login into postgres bash:
sudo docker exec -it 29aab9f62f34 psql -U postgres
Cockroachdb
Redis
Install Docker Compose latest :
sudo curl -SL https://github.com/docker/compose/releases/download/v2.11.2/docker-compose-linux-x86_64 -o /usr/local/bin/docker-compose
sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
docker-compose version
Dump sql for mysql,mariadb into docker
docker exec -i mysqlDocker mysql -uroot -pmypass test < ad_resources21423.sql
docker exec -i mariadbDocker mariadb -uroot -pmypass dev_ad_resources < ad_resources21423.sql
Run Docker without sudo :
1. sudo usermod -aG docker username
2. su - username
3. sudo usermod -aG docker username
Comments
Post a Comment