Last active
December 27, 2016 06:46
-
-
Save shams-ali/2be36936093bef83997f7e2f1522567f to your computer and use it in GitHub Desktop.
Docker Commands
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Go to the directory that has your Dockerfile and run the following command to build the Docker image | |
$ docker build -t <your username>/node-web-app . | |
#to run image and redirect port | |
$ docker run -p 49160:8080 -d <your username>/node-web-app | |
# see running containers | |
$ docker ps | |
# Print app output | |
$ docker logs <container id> | |
# Enter the container | |
$ docker exec -it <container id> /bin/bash | |
#to do get request | |
$ curl -i localhost:49160 | |
#force delete image | |
$ docker rmi -f <container id> | |
#start docker machine, run the command then run the eval command | |
$ docker-machine env | |
#list all machines | |
$ docker-machine ls | |
#remove all images | |
docker rmi $(docker images -q) | |
#remove all containers | |
docker rm $(docker ps -a -q) | |
#copy files into image from host machine | |
# create folders: | |
mkdir /uploads123 | |
mkdir /uploads123/folder1 | |
mkdir /uploads123/folder2 | |
# run container | |
docker run -i -t -v /uploads123:/uploads [IMAGE ID] /bin/bash | |
#copy file from host machine into a running container | |
docker cp foo.txt mycontainer:/foo.txt | |
#compose up a different compose file | |
docker-compose -f docker-compose-production.yml up -d | |
#Create a mysql docker image and mount a volume to seedthrough docker-compose | |
db: | |
image: mariadb | |
ports: | |
- 3306:3306 | |
expose: | |
- 3306 | |
volumes: | |
- ./bondfar.com/db_seeded.sql:/docker-entrypoint-initdb.d/db_seeded.sql:ro | |
environment: | |
- MYSQL_ALLOW_EMPTY_PASSWORD=yes | |
- MYSQL_DATABASE=bondfar | |
- MYSQL_USER=root | |
#-t flag lets you tag your image so it's easier to find later using the docker images command: | |
#-d runs the container in detached mode, leaving the container running in the background. | |
#-p flag redirects a public port to a private port inside the container. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment