Crane Wiki - SnowRipple/Crane GitHub Wiki

Crane Commands Explained

###Build Builds a docker image using Dockerfiles specified in the Cranefile.

crane build [options] <containerName1> <containerName2>

Builds docker images using Dockerfiles specified in Cranefile for and

Note
Docker is a smart beast and it will detect if you are trying to build an image using the same Dockerfile multiple times with different image names. In such case Docker will use already existing image to create a new image with different name but in fact it is the same image all way long with multiple names. If interested you can find out more about docker images/layers magic here.

Another Note
IF you are testing Crane locally AND would like to build docker images using Dockerfiles AND are stuck in a network that does not let you ping even Google DNS 8.8.8.8 in order to build docker images using Dockerfile you have to restart docker daemon with appropriate DNS server:

In terminal separable to the terminal when you run Crane run docker daemon in with the dns option:

sudo docker -d -dns x.x.x.x

You may have to delete the previous docker process first by using:

sudo rm /var/run/docker.pid

Options:

-a (--all) Builds docker images using Dockerfiles from all containers specified in the Cranefile.

###Create Generate an example Cranefile.toml

crane create

Please note that if Cranefile already exists it will be overwritten. For more details about the Cranefile format and use see section " Configuration-Cranefile" above.

###Debug Mode You can use crane in a debug mode which provides much more information about what is happenning behind the scenes and can help you diagnose problems.

crane -d

Using "-d" option will run crane in the debug mode. This option can be used in conjunction will all commands presented below.

###Destroy

Destroy uses "docker kill" and "docker rm" commands to destroy containers.

Firstly crane kills the running/stopped container(s) using "docker kill" command. As a result the container is no longer running but can be started again. Then crane uses "docker rm" command to completely remove the container from the system.

Please note that you can destroy only containers that were created by the crane itself (not manually by docker) and present in the state file(in order to perform an action on a container you must have container ID).

crane destroy

Destroys all containers defined in the Cranefile.

crane destroy <Container1> <Container2>

Destroys containers specified by the user.

###Enter Presents the user with the interactive command line prompt inside a chosen container (you can enter only one container at a time).

crane enter <containerName>

In case of daemonized containers it is necessary to "start" them first before trying to enter them.

###Freeze

crane freeze [options] <containerName1> <containerName2>

Transforms (using docker lingo "commits") containers into immutable images using names defined in Cranefile (overwrites existing images).

crane freeze [options] <containerName1>::<imageName1> <containerName2>::<imageName2>

Transforms (using docker lingo "commits") containers into immutable images with chosen names.

Both options can be used within a single crane command:

crane freeze [options] <containername1> <containerName2>:<imageName2>

Options:

-a (--all) : Freeze all containers defined in the Cranefile into immutable images. Useful when you want to save all your work in one go.

Please note that this command will use existing image names as per Cranefile(overwrite existing images). If you want to freeze a container with a specific name that is different from the original image please use the "freeze" command.

###Pull Pulls images from the docker public repository.

crane pull [options] <image1> <image2>

Pulls chosen images from the public repository.

Options:

-a(--all) : Pulls all images defined in the Cranefile from the docker public repository.

###Rmi Removes docker images specified by the user.

crane rmi [options] <containerName1> <containerName2>

Removes docker images specified in the Cranefile for and .

Options:

-a (--all) Remove all images specified in the Cranefile for all containers.

###Run

Run command is defined in Cranefile or typed from the command line inside specified containers.

In case of daemonized containers you need to start them first in order to run commands inside of them.

crane run [options] <containerName1>:<commandId1>,<commandId2> <containerName2>:<commandId1>

Run commands defined in the Cranefile for each container.

crane run [options] <containerName1>:#"<command1>;<command2>" ... etc

Run commands entered by the user in the command line (no need to add them to the Cranefile).

Please note different delimiters in both cases.

The user can use the mix both methods for different containers using a single command:

crane run [options] <containerName1>:<command1>,<command2> <containerName2>:#"<command1>;<command2>"

Options:

-s="" (--save="") : In order to make the changes made to the container permanent(e.g. you modified a file inside a container that you want to stay this way next time you use that container) you need to transform the container into an immutable image. You can either create a completely new image by providing the name of the new container through using this option or you can simply overwrite the existing image by adding your changes to it e.g.:

crane run -s="goose,dog" gosling:firstCommand,secondCommand puppy:anotherCommand

If you are going to create a completely new image that you are going to reuse with the same container name please remember to change the Cranefile appropriately to reflect those changes(chosen container Image variable).

-u (--update) : It's like an -s option which always overwrites existing images. When present containers are transformed to images which will replace existing images used to create those containers.

###Runall

This command is used to automate multiple run commands.

crane runall

Runs all commands in all containers defined in the Cranefile.

crane runall -c="<CranefileCommand1>;<CranefileCommand2>"

Runs specified Cranefile commands in all containers.

crane runall -o="<ownCommand>;<ownCommand>"

Runs own (not defined in the Cranefile but typed on the commandline) commands in all containers.

crane runall -l="<containerName1>;<containerName2>"

Runs all Cranefile's commands in specified containers.

Please note that All arguments are parsed sequentially so e.g.

crane runall -l="firstContainer;secondContainer"

Will execute all commands in the firstContainer and once finished it will execute all commands in the second container.

The options cannot be used simultaneously within a single "runall" command (but tou can call runall multiple times if you need to use multiple options).

###Start

crane start [options] <containerName1> <containerName2>

Starts all daemonized containers defined in the Cranefile.

Options:

-a(--all) : Starts all daemonized containers defined in the Cranefile.

-f(--force) : Crane assumes that the image already exists in the host system and does not attempt to download it from the docker public repository (useful for offline mode).

⚠️ **GitHub.com Fallback** ⚠️