Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion php/class-ee-docker.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,15 @@ public static function boot_container( $container, $command = '' ) {
}
}

/**
* State of a container as `docker inspect` reports `.State.Running`.
*
* false doesn't mean the container doesn't exist: any inspect failure (no such container, daemon down or restarting, socket error) returns it. Callers that act on its absence (create, remove, "gone") must check that separately.
*
* @param string $container Container name or id.
*
* @return string|false 'running' while it runs, also when paused or restarting; 'exited' for any other state (created, exited, dead); false when inspect fails for any reason. Exits via EE::error() when docker isn't on PATH.
*/
public static function container_status( $container ) {

$exec_command = 'which docker';
Expand All @@ -109,7 +118,7 @@ public static function container_status( $container ) {
if ( $ret ) {
EE::error( 'Docker is not installed. Please install Docker to run EasyEngine.' );
}
$status = EE::launch( "docker inspect -f '{{.State.Running}}' $container" );
$status = EE::launch( "docker inspect -f '{{.State.Running}}' " . escapeshellarg( $container ) );
if ( ! $status->return_code ) {
if ( preg_match( '/true/', $status->stdout ) ) {
return 'running';
Expand Down