Docker Notes


1. Pull a Docker Container with/without tags.

By default, Docker will pull the :latest image.

Pull The busybox image from here: hub.docker.com

docker pull busybox  // same thing as latest
docker pull busybox:latest
docker pull busybox:1.24

2. Run a docker container

docker run -i -t busybox:1.24 // pops an interactive shell
docker run -it busybox:1.24 // same thing, switch -it combined 
docker run -name hello_world busybox:latest echo hello // runs it for a second

3. List Running Containers

docker ps 
  -OR-
docker container list

4. Running a Container with Port

docker run -it -p 8080:8080 tomcat:8.0
- OR - 
docker run -d -it -p 8080:8080 tomcat:8.0 //detached mode
// runs in background
docker logs 33929010101010101 // get logs for -d

5. Save changes to Container

docker ps -a (copy short Container ID)
docker commit 4b6df73fb04a amanda/debian:1.00
sha256:5e38921b9a8ff1980a31d711a008db522f9f24feeda167b6a75501ccb9d925bd
docker images

6. DockerFiles

A Dockerfile is a text document that contains all the instructions users provide to assemble an image.

Try to have as little RUN commands as possible. Chain commands like above.

7. Pushing Docker Image to DockerHub

8. Linking Containers to Talk to Eachother

docker run -d --name redis redis:3.2.0
docker build -t dockerapp:v0.3 .
docker run -p 7000:7000 --link redis dockerapp:v0.3

9. Using Docker Compose

docker-compose up
- OR - 
docker-compose up -d // for background
docker-compose ps
docker-compose logs
docker-compose stop
docker-compose rm
docker-compose build // when you change the yml file.

10. Different Networks in Docker

1. None Network

Disables networking. Unable to reach outside world. Only have a local lo interface. Good choice if you don't need networking.

2. Bridge Network

Default option in Docker containers

3. Host Network

Also known as open containers, least secure.

Comments

Popular posts from this blog

Palo Alto for GNS3 CCDC Tutorial

Trace Labs Global Missing Persons CTF V

Release of CCDC ISE Manager Website