User Tools

Site Tools


docker_cheat_sheet

Docker Check Sheet

Getting Started

docker run --name repo alpine/git ` clone https://github.com/docker/getting-started.git Clone
docker cp repo:/git/getting-started/ . Clone
cd getting-started
docker build -t docker101tutorial . Build
docker run -d -p 80:80 --name docker-tutorial docker101tutorial Run
-d - run the container in detached mode (in the background)
-p 80:80 - map port 80 of the host to port 80 in the container
docker/getting-started - the image to use
docker ps List running Docker processes.
docker stop 6307dc32ab8e Stop a Docker process.
docker rm 6307dc32ab8e Delete a Docker process.
docker rm -f 6307dc32ab8e Stop and delete a Docker process.
-f - force
docker exec aab6865570a6 cat /data.txt Run the cat/data.txt command inside a running Docker process.
docker volume create todo-db Create a volume called todo-db.
docker network create todo-app Create a network called todo-app.
docker run -d `
    --network todo-app --network-alias mysql `
    -v todo-mysql-data:/var/lib/mysql `
    -e MYSQL_ROOT_PASSWORD=secret `
    -e MYSQL_DATABASE=todos `
    mysql:5.7
Start a MySQL container and attach it to the network. Set a couple of variables.
docker exec -it <mysql-container-id> mysql -p Connect to the MySQL database.
docker run -it --network todo-app nicolaka/netshoot Start a new container using the nicolaka/netshoot image.
dig mysql (From inside nicolaka/netshoot) network lookup for the mysql network.
docker-compose up -d Use Docker Compose to run the application stack defined in the docker-compose.yml file.
-d - run the container in detached mode (in the background)
docker-compose logs -f See the logs from each of the services interleaved into a single stream.
docker-compose logs -f <service name> See the logs for a specific service.
docker-compose down Tear down the application.
docker-compose down --volumes Tear down the application and the named volumes.
docker scan <image name> Scan an image for vulnerabilities.
docker image history <image name> Image history and layers.
docker_cheat_sheet.txt · Last modified: 2021/11/04 23:01 by 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki