Skip to content

Instantly share code, notes, and snippets.

@glyons
Last active October 10, 2018 15:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save glyons/c93b1816cef3d8016e2dec494f6776c4 to your computer and use it in GitHub Desktop.
Save glyons/c93b1816cef3d8016e2dec494f6776c4 to your computer and use it in GitHub Desktop.
Docker Command Cheat Sheet and OpenFaas
Python Docker Container
docker pull python
docker pull microsoft/windowsservercore
COMMANDS
=================
To show only running containers use the given command:
docker ps
To show all containers use the given command:
docker ps -a
To show the latest created container (includes all states) use the given command:
docker ps -l
To show n last created containers (includes all states) use the given command:
docker ps -n=-1
To display total file sizes use the given command:
docker ps -s
The content presented above is from docker.com.
In the new version of Docker, commands are updated, and some management commands are added:
docker container ls
Is used to list all the running containers.
docker container ls -a
Is used to list all the containers created irrespective of its state.
Here container is the management command.
To list all running and stopped containers
docker ps -a
To list all running containers (just stating the obvious and also example use of -f filtering option)
docker ps -a -f status=running
To list all running and stopped containers, showing only their container id
docker ps -aq
To remove all containers that are NOT running
docker rm `docker ps -aq -f status=exited`
Connect to Web Interface of the Docker Container
===================================================
docker container ls port outside
Getting OpenFaaS up and running
======================
cd c:\git
cd C:\git\faas
git clone https://github.com/openfaas/faas
echo "user01" | docker secret create basic-auth-user -
echo "secretsecret" | docker secret create basic-auth-password -
\deploy_stack.ps1
To list all the Functions on OpenFaas
http://localhost:8080/system/functions
Install FaasCli on WIndows
=============================
1. Install Scoop (Powershell Ver.3 only) iex (new-object net.webclient).downloadstring('https://get.scoop.sh')
2. scoop install faas-cli
Faas-CLi
https://github.com/openfaas/faas-cli
OpenFaas Video
=====================
https://www.youtube.com/watch?v=BK076ChLKKE
Run a loop in Windows Powershell to call the Hash Function
=============================================================
while($true) { Start-Sleep 0.1; curl http://localhost:8080/function/hash?blahblah }
If you bore why not make a light board!
https://www.youtube.com/watch?v=wNnsU1e8uoM
Kubeclient .NET
https://github.com/tintoy/dotnet-kube-client
Token
======
e.g docker swarm join --token SWMTKN-1-4j78ll553ozhwwhme0p79v9l7ik9gxq6lwp9iml6-bj2k5r1ssuccf7xxveeji2tnm 192.168.1.3:2377
If you've lost this info then type in docker swarm join-token worker and then enter that on the worker.
Once Kubenetes is installed
Try kubectl config get-contexts (from PowerShell on Windows)
MongoDb
==============
Run in Powershell / sh
faas-cli template pull https://github.com/openfaas-incubator/node8-express-template
Curl within a Container to Openfaas Container
================================================
unset http_proxy // if you've set a proxy in your Dockerfile
curl -d"dddmmaffdffd#m" gateway:8080/function/Echo
sending to a NodeJS function in openfaas
curl gateway:8080/function/mongo-insert -d '{"name":"TEST1"}' -H "Content-Type:application/json"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment