Some useful Docker commands
Lately I've been using Docker quite often and loving it, as it makes it really simple to deploy applications. Today I will discuss some useful Docker commands that are handy.
1. Docker exec
Let us say you are running a docker container in detached mode, you can still directly execute commands on it, using docker exec. For example, if you want to open a file using vim in docker for editing it, you can issue the following command.
docker exec -it container_name sh -c 'vi somedirinsidedocker/somefile.txt'
2. Docker container start
If for some reason you want to stop a container for a moment, you can restart it by using this command. For stopping a container you use docker stop container_name, while for restarting it, you would use docker container start container_name.
3. Docker inspect
You can use this command to get all the details about a container, such as its IP Address for example. The syntax is docker inspect container_name. If you want to see a specific attribute, you can use grep for filtering it out. For example, for knowing the IP address, we would use docker inspect container_name | grep IPAddress.
4. Docker cp
With this command, you can copy files/folders between host and the container. To copy from host to container, use docker cp file_or_folder_on_host container_name:destination_folder_on_container. To copy from container to host, use docker cp container_name:file_or_folder_on_container destination_folder_on_host.
5. Docker rename
This command renames a container. Example usage is docker rename old_name new_name.
For the full list of commands, you can visit https://docs.docker.com/engine/reference/commandline/docker/.
Leave Some useful Docker commands to:
Read more #technology posts
Best Posts From hmushtaq
We have not curated any of hmushtaq's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.
More Posts From hmushtaq
- My trip to Instanbul
- Sharing Linux Folders with Windows through Samba
- My trip to Jurassic Kingdom
- My trip to Plaswijkpark
- Which teams do you think would reach the Quarter finals of the 2018 Football World Cup?
- Does Japan deserve to be in the 2nd round?
- I have made a site to check the prices of Cryptocurrencies
- Coinmarket showing the value of SBD almost twice as much as the original!
- My trip to Grenoble, France
- Some useful Docker commands
- CloudVPS, VPS hosting on Openstack
- Why stopping eating white sugar is so beneficial
- Why one must not panic when crypto prices are going down
- How to stay safe while surfing the net
- NASA thinks there is possibility of life on Jupiter's moon Europa
- Four lions vs a duck!
- Student used phishing attack to change grades
- NASA will send a helicopter to Mars!
- 1000 followers on Steemit!
- Why Crytpo market has gone red suddenly?