Development process before containers? If your app uses 10 services, each developer needs to install these 10 services.
Development process:
Development process with containers? Standardizes process of running any services on any local dev environment.
Development process:
docker
upgrade –
docker images
docker ps = list running contaniers
How do we get these images?
Pull Docker Hub registry (docker.io) is used by default.
docker pull {name}:{tag} = Pull an image from a registry
docker images
Run
docker run {name}:{tag} = creates a container from given images and starts it
docker ps
docker -d = runs container in background and prints the container ID
you may still want to see the logs,which can be useful for debugging etc.
docker logs {container} = view logs from service running inside the container.
give a name --name
docker run --name web-app -d -p 9000:80 nginx:1.23
Port Binding
localhost:80
cannot be reached
only run with additional tag:
docker stop {container} = stop one or more running containers
-p or --publish = pubish a container's port to the host
-p {HOST_PORT}:{CONTAINER_PORT}
all in all
docker run -d -p 9000:80 niginx:1.23
docker ps
only list the running containers. To list all containers (stopped and running) by using flag -a
or --all
docker ps -a
stop
docker stop {containerID}
start
docker start {containerID} = start one or more stopped containers
logs
docker logs {containerID/NAME}
CMD ["node", "server.js"]
docker build {path} = Builds a Docker image from a Dockerfile
Sets a name and optionally a tag in the “name:tag” format
docker build -t node-app:1.0 .
“latest” tag mostly refers to the newest release.
How Docker fits in the complete development and development process?