Closed ignlg closed 8 years ago
I'm not sure what you are trying to do. Do you mean the container was destroyed so you needed another one with the same config/volume?
Exactly. I need to start a new container but keep the config/volume.
create
says that the service already exists.
start
says that no container exists.
And both are right.
I was stuck so I created this command:
$PLUGIN_COMMAND_PREFIX:deploy)
[[ -z $2 ]] && dokku_log_fail "Please specify a name for the service"
[[ -d "$PLUGIN_DATA_ROOT/$2" ]] || dokku_log_fail "$PLUGIN_SERVICE service $2 does not exist"
SERVICE="$2"; SERVICE_ROOT="$PLUGIN_DATA_ROOT/$SERVICE"; LINKS_FILE="$SERVICE_ROOT/LINKS"
if ! docker images | grep -e "^$PLUGIN_IMAGE " | grep -q " $PLUGIN_IMAGE_VERSION " ; then
dokku_log_fail "$PLUGIN_SERVICE image $PLUGIN_IMAGE:$PLUGIN_IMAGE_VERSION not found"
fi
rootpassword=$(cat "$SERVICE_ROOT/ROOTPASSWORD")
password=$(cat "$SERVICE_ROOT/PASSWORD")
dokku_log_info1 "Starting container"
SERVICE_NAME=$(get_service_name "$SERVICE")
ID=$(docker run --name "$SERVICE_NAME" -v "$SERVICE_ROOT/data:/var/lib/mysql" -e "MYSQL_ROOT_PASSWORD=$rootpassword" -e MYSQL_USER=mariadb -e "MYSQL_PASSWORD=$password" -e "MYSQL_DATABASE=$SERVICE" -d --restart always --label dokku=service --label dokku.service=mariadb "$PLUGIN_IMAGE:$PLUGIN_IMAGE_VERSION")
echo "$ID" > "$SERVICE_ROOT/ID"
dokku_log_verbose_quiet "Waiting for container to be ready"
docker run --rm --link "$SERVICE_NAME:$PLUGIN_COMMAND_PREFIX" dokkupaas/wait > /dev/null
dokku_log_info2 "$PLUGIN_SERVICE container created: $SERVICE"
dokku "$PLUGIN_COMMAND_PREFIX:info" "$SERVICE"
;;
That is like create
but it reads the configuration instead of creating/writing it.
start
should probably warn and then create the container. That seems reasonable to me. Mind creating a pr with that functionality? I can port it to the other containers once you do.
Sure, I was waiting to discuss if it should be a new command or not to create a PR. And I have the answer now :)
Closed by #44
I want to call for ideas to add a new command to deploy a new container with existent configuration.
This was the case: While I was cleaning up docker containers and images, I destroyed a
dokku-mariadb
container that was stopped earlier. I've found that there's no command to deploy again adokku-mariadb
container.mariadb:create
creates a new configuration andmariadb:start
doesn't found the old container.I ended up creating a new command
mariadb:deploy
that is similar tomariadb:create
but it reads the actual configuration to deploy the container.As I could end up pushing the feature to other plugins like
dokku-mongo
, etc, I would want to quickly discuss with you the right name and description for the command.What do you think?