Skip to content

Instantly share code, notes, and snippets.

@DevWichrowski
Created March 30, 2018 13:15
Show Gist options
  • Save DevWichrowski/764226448539bd8aa9c1d982cb9efd67 to your computer and use it in GitHub Desktop.
Save DevWichrowski/764226448539bd8aa9c1d982cb9efd67 to your computer and use it in GitHub Desktop.
=========Docker Basics===========
docker login - to login into docker hub
docker run - to run container
docker rm - to remove container from sys
docker rmi - to remove container from disk
docker kill- to close
docker ps - list running containers
docker ps -a shows stopped containers
docker ps -l shows last runned container
docker logs - show log of container
-f to stay in
docker inspect - to inspect a container
--format='{{.NetworkSettings.IPAddress}}' containerName - to get only searched info
docker run -i -t container /bin/bash - to enter into interactive shell
docker exec -i -t container /bin/bash - allows us to run more than one shell
============Docker Images=============
ocker pull image - to pull image
docker pull image:3.5.0-lorem - to pull a tagged image
docker search - to search for a image
hostname - to get container id where we are in
docker commit -m "installed node and wrote average application" 960baf2a8bf4 - to commit and save a container status
docker run containerID average/average.js 3 4 5 - to run docker container and script
docker tag 2cd848f9e341 patryk/hello-dockerhub:1.0 - to tag a image
docker build . - to run dockerfile if we are in right folder
docker build -t patryk/average . - to build and name
docker run -p 4567:4567 --link redis:redis2 patryk/count - to map port
docker run ls -l to list all files in current directory
========================Dockerfile====================================
FROM alpine - from which container
RUN apk update && apk add nodejs - to run issue command
RUN mkdir average
ADD average.js average/ - adding js file to average directory / docker context
WORKDIR average - we are setting working directory
ENTRYPOINT["node","average.js"] - define the main process in the container
==========================DOCKER NETWORKING==============================
docker network ls - list a network list
docker run -d -P --net none - run on bridge network
docker network create --driver bridge myNetwork - to create own network
--net - we use this flag to choose in which network image will run
==========================Docker Compose==============
docker-compose up - will run all services specified in our file
docker-compose stop/ctrl-C - to stop all containers
docker-compose rm - to remove containers from disk
=========================Docker Swarm=================
docker swarm init --advertise-addr <MANAGER-IP> - to run new swarm
docker swarm join \ - add worker to swarm
docker info - to check info about swarm
docker node ls - view information about nodes:
docker-machine create --driver virutalbox node1 - to create docker host
docker service create --replicas 1 --name helloworld alpine ping docker.com - to create and add service to swarm
docker service inspect --pretty <SERVICE-ID> - to inspect service
docker service ps <SERVICE-ID> to see which nodes are running the service
docker service rm helloworld - to remove service
docker service update - to update service
docker run -d -p 2181:2181 --name zookeeper jplock/zookeeper - to run zookeeper
docker run -d -p 3376:3376 --name manager -t -v /var/lib/boot2docker:/certs:ro swarm manage -H tcp://0.0.0.0:3376 --tlsverify --tlscacert=/certs/ca.pem --tlscert=/certs/server.pem --tlskey=/certs/server-key.pem zk://localhost:2181 - start swarm menager to menage clusters
@DevWichrowski
Copy link
Author

Docker-Compose logs -f backend

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment