Spinning Up A Local Swift Instance
In this quickstart, we will download a OpenStack Swift Image, spinup a container on a single machine, upload a test file, and download that file.
Prerequisites
You will need:
- Docker command line tool
- Python 3
Getting started
To download the image, issue the following commands in your terminal:
docker pull fnndsc/docker-swift-onlyone
Setup Volume for Swift
Volumes are the preferred mechanism for persisting data generated by and used by Docker containers.
docker volume create swift_storage
Start up Container Instance
docker run -d --name swift-onlyone -p 12345:8080 -v swift_storage:/srv -t fnndsc/docker-swift-onlyone
Setup Swift Client
Querying Swift through command line requires python-swiftclient. We'll need to install it:
pip3 pip install python-swiftclient
If you are on Mac OS, which has Apple Swift overriding Openstack swift package, explicitly invoking swiftclient as /usr/bin/local/swift works.
In case the absolute path is not
/usr/bin/local/swift
, trysudo find / -name swift
which will give you a list that contains the right > executable pathFor example,
/usr/local/bin/swift -A http://127.0.0.1:12345/auth/v1.0 -U chris:chris1234 -K testing stat
should work. We will keep using/usr/local/bin/swift
afterwards
Create, Upload, and Download a Test File
We've create an empty file called test-file.txt
to get you started:
touch test-file.txt
To upload this file onto Swift:
/usr/local/bin/swift -A http://127.0.0.1:12345/auth/v1.0 -U chris:chris1234 -K testing upload --object-name
test-file.txt user_uploads ./test-file.txt
which will print the name of the file if the upload was successful:
test-file.txt
To download that file:
/usr/local/bin/swift -A http://127.0.0.1:12345/auth/v1.0 -U chris:chris1234 -K testing download user_uploads test-file.txt