In order to get logs of docker container, we can use this command –
docker logs <container_id>
Or,
docker logs <container_name>
For our example of mongodb, let’s first run a container –
docker run -d --name mongo-container mongo

Now let’s check which containers are running –
docker ps

We can see that our mongo container is running under the name mongo-container
. To get the logs of this container –
docker logs mongo-container
or we can use the container id –
docker logs 6bd3e72

Kubernetes Series
- Introduction to Kubernetes
- Introduction to Docker, Containers, Images & Repository
- Install and Run Docker Images
- Docker Image – FROM, RUN, COPY, ENTRYPOINT, CMD, EXPOSE explained
- Why docker run or start command not running my container?
- How to list all docker images in system?
- How to list all docker containers?
- How to start/stop a docker container?
- Difference between docker run and docker start
- How to bind docker container port with host?
- How to get logs of docker container?
- How to live stream logs of docker container?
- Set custom name to a docker container
- Access docker container filesystem & terminal
- Getting docker details using docker inspect
- Kyverno – Installation, Policies, Testing, Reporting, Monitoring, Security
- Complete Kubernetes Project Step By Step
- Introduction to Kubernetes Objects