📅  最后修改于: 2023-12-03 15:00:29.539000             🧑  作者: Mango
Docker Runlike is a Bash script that prints the Docker command line that would be needed to create a new container identical to an existing container. This is particularly useful in situations where it's necessary to create a new container with the same configuration as an existing container. Instead of manually recreating the container settings, the Docker Runlike script automatically generates the necessary command line arguments.
The Docker Runlike script can be downloaded from the official GitHub repository:
$ curl https://raw.githubusercontent.com/lukasmartinelli/runlike/master/runlike.sh -o runlike.sh
$ chmod +x runlike.sh
To use Docker Runlike, simply run it with the ID or name of the container that you want to replicate:
$ ./runlike.sh <container_id_or_name>
The script will output a Docker command that can be used to create a new container with the same configuration as the original container. For example:
# ./runlike.sh my-container
docker run -it --rm --name my-container \
-e "VAR1=value1" \
-e "VAR2=value2" \
--link my-database:database \
my-image:latest
The generated command line arguments can be customized by modifying the runlike.sh
script. By default, the script includes the following options:
-it
: runs the container in interactive mode with a TTY attached.--name
: specifies the name of the new container.-e
: sets environment variables on the new container.--link
: links the new container to an existing container.Docker Runlike is a small but useful utility that simplifies the process of creating new containers based on existing configurations. Whether you're deploying applications in production or testing new configurations, Docker Runlike can save you time and effort by automating the creation of new containers.