Create Dockerfile and .dockerignore
docker build -t [name] . docker run -it -p [your port]:[container port] [name]
1) Build Image with Dockerfile
-t names build, . says which files to use
-t
.
-f [DOCKERFILE PATH] lets you specify Dockerfile
-f [DOCKERFILE PATH]
2) Run It
it allows Ctrl-C to stop it
Ctrl-C
-p 80:4000 means in container runs on port 4000, but you can access at localhost:80
-p 80:4000
-d runs in detached mode
-d
-it runs in interactive mode so you can kill
-it
-v "$(pwd)"/backend:/app mounts the files at /backend to the docker containers /app allowing instant changes!
-v "$(pwd)"/backend:/app
Its possible to use a -v to mount your filesystem to the contianer auto updating on changessss
docker exec -it <container id> <command> => Execute command in running docker container
docker exec -it <container id> <command>
docker exec -it <container id> /bin/sh => Get bash
docker exec -it <container id> /bin/sh
Kill Docker Container
docker kill $(docker ps -q)
Tag for identification
Convention is reponame = username/reponame
Last updated 6 years ago
docker tag [image] [reponame]:[tag] docker tag test jjfuentes/test:part1 docker push jjfuentes/test:part1