Difference between revisions of "Docker tutorial"
Jump to navigation
Jump to search
(5 intermediate revisions by the same user not shown) | |||
Line 24: | Line 24: | ||
docker rmi nginx | docker rmi nginx | ||
will delete the image permanently | will delete the image permanently | ||
docker inspect container_name | |||
get more info on a container | |||
docker logs container_name | |||
show logs of a container | |||
==Persistent Data== | |||
''' if you create a mysql docker container and store everything in the container, when you delete the container everything will be lost''' | |||
''''To store the msql files outside the container , you would have to map the storage to an outside directory''' | |||
docker run -v /opt/datadir:/var/lib/mysql mysql | |||
this will mount the /opt/datadir to the internal /var/lib/mysql folder | |||
docker pull nginx | docker pull nginx | ||
will pull the nginx image down but not run it | will pull the nginx image down but not run it | ||
docker exec nameofdockerinstance cat/etc/hosts | |||
run a command withing the docker instance | |||
run redis:4.0 | |||
run a specific version of a software | |||
docker run -it ubuntu | |||
run an app and attach to it terminal in an interactive mode | |||
==Port Mapping== | |||
''' Every docker container get's a local ip assigned (internal)''' | |||
'''you have top map the internal port to the external ip and port''' | |||
docker run -p 80:5000 webapp | |||
80 is the external port and 5000 is the internal port | |||
==[[Docker]]== | ==[[Docker]]== |
Latest revision as of 20:22, 2 May 2022
Installing Docker on Ubuntu =
curl -fsSL https://get.docker.com -o get-docker.sh sudo sh get-docker.sh
Docker Commands
docker run application Run application, if it does not exist, it will pull it down
docker ps list all running containers
docker ps -a see all running container
docker stop stop a container
docker rm remove a container
docker images list images locally
docker rmi nginx will delete the image permanently
docker inspect container_name get more info on a container
docker logs container_name show logs of a container
Persistent Data
if you create a mysql docker container and store everything in the container, when you delete the container everything will be lost 'To store the msql files outside the container , you would have to map the storage to an outside directory
docker run -v /opt/datadir:/var/lib/mysql mysql this will mount the /opt/datadir to the internal /var/lib/mysql folder
docker pull nginx will pull the nginx image down but not run it
docker exec nameofdockerinstance cat/etc/hosts run a command withing the docker instance
run redis:4.0 run a specific version of a software
docker run -it ubuntu run an app and attach to it terminal in an interactive mode
Port Mapping
Every docker container get's a local ip assigned (internal) you have top map the internal port to the external ip and port
docker run -p 80:5000 webapp 80 is the external port and 5000 is the internal port