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/.
very useful article.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
As a follower of @followforupvotes this post has been randomly selected and upvoted! Enjoy your upvote and have a great day!
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
i think you got something wrong with your docker start command. shouldnt it be just "docker start container_name"?
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Check it yourself from Docker's official documentation, https://docs.docker.com/engine/reference/commandline/container_start/
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit