You want to start a docker container quickly, but you dont remember all the small details like…
chatgpt is here! no idea if it will make developers/system admins obsolete in the long term, but for now, I am convinced that it can help…
You want to start a docker container quickly, but you dont remember all the small details like ports? use chatgpt
chatgpt is here! no idea if it will make developers/system admins obsolete in the long term, but for now, I am convinced that it can help my weak memory when it comes to remembering small things like parameters, port numbers, etc; one example is Docker, it has many parameters, and I don’t have the good habit of using docker-compose, but I prefer every time to suffer and re-write all the commands. However, Ivstill would like some help from time to time, chatgpt can solve this problem! Lets see how!
How to use chatgpt from the command line and the web
The most well known way to interact with chatgpt is using the web interface, another way if you using the paid version is to use a command line interface for chatgpt, i have made a command line interface for chatgpt but i am quite sure that there are myriad other tools like this.
You can check mine here
kpatronas/shellgpt: Query chatgpt from your shell (github.com)
How to ask chatgpt to create a container for you
Either you using the web interface or another way the question would be the same
chatgpt -p "Create a docker command that will use the mysql image, use persistent storage and will expose the database port and will delete container afte
r exiting, mysql root password is test"In simple english, we ask to
- Create a Docker command.
- Use the MySQL image
- Use persistent storage (we dont want to lose our files after exiting the container)
- Map MySQL port to the local machine port
- And delete the container after exiting.
The output is
docker run --rm -v mysqldata:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=test -p 3306:3306 mysqlThe only change we need to do is to change the /my/own/datadir to a path existing to our filesystem.
We can verify the result by executing the command
docker run --rm -v mysqldata:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=test -p 3306:3306 mysql
kpatronas@nautilus:~$ docker run --rm -v mysqldata:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=test -p 3306:3306 mysql
2023-02-07 13:41:16+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.32-1.el8 started.
2023-02-07 13:41:17+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2023-02-07 13:41:17+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.32-1.el8 started.
2023-02-07 13:41:17+00:00 [Note] [Entrypoint]: Initializing database filesConclusion
chatgpt can help us with small things very well, it can remind us how we can do something with a great chance of success without googling pages, but this is maybe its greatest weakness, it gives only one result without any references, but still is a precious tool.