Skip to content

Latest commit

 

History

History
111 lines (92 loc) · 1.7 KB

install-docker.md

File metadata and controls

111 lines (92 loc) · 1.7 KB

INSTALL DOCKER

OS UPDATE

sudo yum update

SEARCH FOR DOCKER

sudo yum search docker
sudo yum info docker

INSTALL DOCKER

sudo yum install docker -y

ADD CURRENT USER TO DOCKER GROUP

sudo usermod -a -G docker $USER

VERIFY GROUP MEMBERSHIP

id 
exit

ENABLE AND START DOCKER

sudo systemctl enable docker.service
sudo systemctl start docker.service
systemctl status docker.service

LIST DOCKER IMAGES

docker images

LIST DOCKER CONTAINERS

docker ps

SEARCH FOR MYSQL

docker search mysql

PULL MYSQL DOCKER IMAGE

docker pull mysql
docker images

INSPECT MYSQL DOCKER IMAGE

docker inspect mysql

RUN MYSQL CONTAINER

docker run --name mysql-831 -e MYSQL_ROOT_PASSWORD=P@ssw0rd -d mysql:latest

VERIFY IF MYSQL IS RUNNING AS CONTAINER

docker container ps
pidof mysqld
sudo netstat -ntlp | grep 3306 <-- No, why?

INSPECT MYSQL CONTAINER

docker container inspect mysql-831

MYSQL CONTAINER LOGS

docker logs mysql-831

MYSQL CONTAINER HOST

docker exec -it mysql-831 bash
mysql -u root -p

REMOVE MYSQL CONTAINER

docker container stop mysql-831
docker ps
docker ps -a
docker container --help
docker container rm --help
docker container rm -fv mysql-831 

EXPOSE CONTAINER PORT TO HOST

docker container run --name mysql-831 -e MYSQL_ROOT_PASSWORD=P@ssw0rd -d --publish 3306:3306 mysql:latest

BIND LOCAL VOLUME

mkdir mysql-data
docker run --name mysql-831 -e MYSQL_ROOT_PASSWORD=P@ssw0rd -d -p 3306:3306 -v /home/ec2-user/mysql-data:/var/lib/mysql mysql:latest
ls -ltr mysql-data