Lets Docker up!: Chapter 1

I havent been really gotten into dockering much. Although I used on my wordpress development stuff using docker-compose. I get the idea behind it. But right now , I just wanna go at it from the beginning. To refresh my memory.

Chapter 1:

We know so far, docker containers are created from an image. You either create your container from a dockerfile inside a folder or create it via command line. First we need to familiar ourselves with  some commands. Also refer to this site for the list of commands

https://docs.docker.com/engine/reference/commandline/docker/

docker build -t [image_name:any_tag] [context_path or path_to your_dockerfile] – build the image based on a docker file. -t option is to name your image.

docker run -p 8084:80 [image_name] – this is to run the image that were created. -p is the port we need to expose to access the container port. 8084 is the port of the host pc and 80 port of the containers. -v mounting a volume so you can change the files inside the container folder. -v [absolute_path:container_path]. Important note: relative path for host doesnt work and must be an absolute path for the host. Funnily enough relative volumes on docker-compose works.

docker ps – basically list all running containers running so far. You can use -a to also shows non-running containers.

docker image ls – list all your images currently available.

docker rm [container_id] – remove the container

docker image rm [image name:latest or image_id] – remove the image. -f force image to be deleted.

docker stop [container_id] – stop the container from running.

Leave a Reply

Your email address will not be published. Required fields are marked *