Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Working with Docker -- Just Tips and Tricks Stuff
docker-machine ls (this list all the machine that you have locally)
docker-machine start [machine name]
docker-machine stop [machine name]
docker-machine env [machine name]
docker-machine ip [machine name]
docker-machine status [machine name]
docker ps (this list all containers)
# Run this command to configure your shell:
# eval $(docker-machine env default)
docker-machine (this list all of the commands available)
---------------Docker Client ---------------------
docker pull [image name]
docker run [image name]
eg docker run -p 80:80 kitematic/hello-world-nginx
docker images
docker ps
docker ps -a (shows all images even ones not running)
docker rm [container id] this removes the container
docker rmi [image id]
------ Getting Source Code into a Container ---
1. Create a Container Volume that points to ta Source Code
2. Add Code to a custom image
Layerd File System
Store Files and Codes in VOlumes that site inside Containers
Volume writes to the Host machine that is Mounted i.e. if you delete the container it is still there. as oppose to the thin read write layer
--- Create a Data Volume ----
docker run -p 8080: 3000 -v /var/www node
docker inspect [container name] -- this will look for mounted areas where volume are stored
-- Customizing Volumes
docker run -p 8080:3000 -v $(pwd):/var/www node
-- to remove volumes in a container you can do --
docker rm -v [container id]
to make this work using your own volume in a container
docker run -p 8080:3000 -v $(pwd):/var/www -w "/var/www" node npm start
-- Building a Custom Image --
docker build -t <your username>/node .
you can use a npm tool RimRaf to delete items
--- publish to docker hub --
docker push <your username> / node -- basdically the name of the image you built
from prompt
docker login
---- to create my custom image ---
dotnet publish
docker build -t fabsdockone .
docker run -d -p 8080:58036 fabsdockone
-- to test
docker ps
-- if issue then
docker ps -a
--- if your image doesnt have a tag ie. your username you have to tag it before you can push it --
docker tag firstimage YOUR_DOCKERHUB_NAME/firstimage
--- push to docker hub ---
docker push [username]/image name
--- if you want to pull you image now that it is built
docker pull fabianwilliams/fabsdockone
-- linking containers ---
1. Build the Image that you will be using
docker build -f aspnetcore.dockerfile -t fabianwilliams/fabsdockone
2. Start the Container you want to link to
docker run -d --name my-mongodb mongo
3. Start the Container that will refernce the Linked Container with alias
docker run -d -p 8080:56356 --link my-mongodb:mongodb fabianwilliams/node
---- using Custom Bridge Network for LInking ----
docker network create --driver bridge [nameofnetwork]
now run the container
dockeer run -d --net=[networkname] -- name [continername] [name]
--- you can execute a command in a running container ---
docker exec [container name /id] node dbSeeder.js
-- to list Networks in Docker ---
docker network ls
-- to inspect --
docker network inspect [network name]
--- Docker Composte --
docker-compose build
docker-compose up
docker-compose down
----- creating a docker conainer for SQL ----
get the image
docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=<YourStrong!Passw0rd>' -p 1433:1433 -d microsoft/mssql-server-linux
docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=P@ssw0rd1!' -p 1433:1433 -d microsoft/mssql-server-linux
mssql -s localhost -u sa -p P@ssw0rd1!
-- Learn how to Manage DBs on CLI ---
---- Docker Compose ---
docker-compose build
docker-compose up
docker-compose up -d (this runs it in deamon mode so the terminal window is not blocked.. ie. it runs behind the scenes)
docker-compose ps (this lets you know what is running)
docker-compose logs
docker-compose down
docker-compose start
docker-compose stop
docker-compose down --rmi all --volumes
Azure CLI to do ARM
0. To change your Azure Subscription to the one you want to work with
azure account set <subscription name or ID> true
1. Create a resource group
azure group create myResourceGroup eastus2
2. -- Create a Swarm VM
azure group deployment create --template-uri 3rdrock-docker-alpha FabsDockerDeployment1
with Azure Extensions use
3. Delete Resource Group and all Resoures within
azure group delete myResourceGroup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment