怎么干净的卸载docker(docker,web开发)

时间:2024-05-06 12:43:53 作者 : 石家庄SEO 分类 : web开发
  • TAG :

先上服务器环境信息:

怎么干净的卸载docker

卸载的原因:

宿主机过段时间就磁盘100%了,导致continart异常退出,后来找了很多解决方案,才发现是安装docker的时候有个配置文件错误(正常的应该是|storage driver: overlay2)。

怎么干净的卸载docker

上干货:

①卸载

yumremovedocker\docker-client\docker-client-latest\docker-common\docker-latest\docker-latest-logrotate\docker-logrotate\docker-selinux\docker-engine-selinux\docker-enginerm-rf/etc/systemd/system/docker.service.drm-rf/var/lib/dockerrm-rf/var/run/docker

②安装

#!/bin/shset-e#thisscriptismeantforquick&easyinstallvia:#$curl-fsslget.docker.com-oget-docker.sh#$shget-docker.sh##fortestbuilds(ie.releasecandidates):#$curl-fssltest.docker.com-otest-docker.sh#$shtest-docker.sh##note:makesuretoverifythecontentsofthescript#youdownloadedmatchesthecontentsofinstall.sh#locatedathttps://github.com/docker/docker-install#beforeexecuting.##gitcommitfromhttps://github.com/docker/docker-installwhen#thescriptwasuploaded(shouldonlybemodifiedbyuploadjob):script_commit_sha=36b78b2#thisvaluewillautomaticallygetchangedfor:#*edge#*test#*experimentaldefault_channel_value="edge"if[-z"$channel"];thenchannel=$default_channel_valuefidefault_download_url="https://download.docker.com"if[-z"$download_url"];thendownload_url=$default_download_urlfidefault_repo_file="docker-ce.repo"if[-z"$repo_file"];thenrepo_file="$default_repo_file"fisupport_map="x86_64-centos-7x86_64-fedora-26x86_64-fedora-27x86_64-fedora-28x86_64-debian-wheezyx86_64-debian-jessiex86_64-debian-stretchx86_64-debian-busterx86_64-ubuntu-trustyx86_64-ubuntu-xenialx86_64-ubuntu-bionicx86_64-ubuntu-artfuls390x-ubuntu-xenials390x-ubuntu-bionics390x-ubuntu-artfulppc64le-ubuntu-xenialppc64le-ubuntu-bionicppc64le-ubuntu-artfulaarch64-ubuntu-xenialaarch64-ubuntu-bionicaarch64-debian-jessieaarch64-debian-stretchaarch64-debian-busteraarch64-fedora-26aarch64-fedora-27aarch64-fedora-28aarch64-centos-7armv6l-raspbian-jessiearmv7l-raspbian-jessiearmv6l-raspbian-stretcharmv7l-raspbian-stretcharmv7l-debian-jessiearmv7l-debian-stretcharmv7l-debian-busterarmv7l-ubuntu-trustyarmv7l-ubuntu-xenialarmv7l-ubuntu-bionicarmv7l-ubuntu-artful"mirror=''dry_run=${dry_run:-}while[$#-gt0];docase"$1"in--mirror)mirror="$2"shift;;--dry-run)dry_run=1;;--*)echo"illegaloption$1";;esacshift$(($#>0?1:0))donecase"$mirror"inaliyun)download_url="https://mirrors.aliyun.com/docker-ce";;azurechinacloud)download_url="https://mirror.azure.cn/docker-ce";;esaccommand_exists(){command-v"$@">/dev/null2>&1}is_dry_run(){if[-z"$dry_run"];thenreturn1elsereturn0fi}deprecation_notice(){distro=$1date=$2echoecho"deprecationwarning:"echo"thedistribution,$distro,willnolongerbesupportedinthisscriptasof$date."echo"ifyoufeelthisisamistakepleasesubmitanissueathttps://github.com/docker/docker-install/issues/new"echosleep10}get_distribution(){lsb_dist=""#everysystemthatweofficiallysupporthas/etc/os-releaseif[-r/etc/os-release];thenlsb_dist="$(./etc/os-release&&echo"$id")"fi#returninganemptystringhereshouldbealrightsincethe#casestatementsdon'tactunlessyouprovideanactualvalueecho"$lsb_dist"}add_debian_backport_repo(){debian_version="$1"backports="debhttp://ftp.debian.org/debian$debian_version-backportsmain"if!grep-fxq"$backports"/etc/apt/sources.list;then(set-x;$sh_c"echo\"$backports\">>/etc/apt/sources.list")fi}echo_docker_as_nonroot(){ifis_dry_run;thenreturnfiifcommand_existsdocker&&[-e/var/run/docker.sock];then(set-x$sh_c'dockerversion')||truefiyour_user=your-user["$user"!='root']&&your_user="$user"#intentionallymixedspacesandtabshere--tabsarestrippedby"<<-eof",spacesarekeptintheoutputecho"ifyouwouldliketousedockerasanon-rootuser,youshouldnowconsider"echo"addingyourusertothe\"docker\"groupwithsomethinglike:"echoecho"sudousermod-agdocker$your_user"echoecho"rememberthatyouwillhavetologoutandbackinforthistotakeeffect!"echoecho"warning:addingausertothe\"docker\"groupwillgranttheabilitytorun"echo"containerswhichcanbeusedtoobtainrootprivilegesonthe"echo"dockerhost."echo"refertohttps://docs.docker.com/engine/security/security/#docker-daemon-attack-surface"echo"formoreinformation."}#checkifthisisaforkedlinuxdistrocheck_forked(){#checkforlsb_releasecommandexistence,itusuallyexistsinforkeddistrosifcommand_existslsb_release;then#checkifthe`-u`optionissupportedset+elsb_release-a-u>/dev/null2>&1lsb_release_exit_code=$?set-e#checkifthecommandhasexitedsuccessfully,itmeanswe'reinaforkeddistroif["$lsb_release_exit_code"="0"];then#printinfoaboutcurrentdistrocat<<-eofyou'reusing'$lsb_dist'version'$dist_version'.eof#gettheupstreamreleaseinfolsb_dist=$(lsb_release-a-u2>&1|tr'[:upper:]''[:lower:]'|grep-e'id'|cut-d':'-f2|tr-d'[:space:]')dist_version=$(lsb_release-a-u2>&1|tr'[:upper:]''[:lower:]'|grep-e'codename'|cut-d':'-f2|tr-d'[:space:]')#printinfoaboutupstreamdistrocat<<-eofupstreamreleaseis'$lsb_dist'version'$dist_version'.eofelseif[-r/etc/debian_version]&&["$lsb_dist"!="ubuntu"]&&["$lsb_dist"!="raspbian"];thenif["$lsb_dist"="osmc"];then#osmcrunsraspbianlsb_dist=raspbianelse#we'redebiananddon'tevenknowit!lsb_dist=debianfidist_version="$(sed's/\/.*//'/etc/debian_version|sed's/\..*//')"case"$dist_version"in9)dist_version="stretch";;8|'kalilinux2')dist_version="jessie";;7)dist_version="wheezy";;esacfififi}semverparse(){major="${1%%.*}"minor="${1#$major.}"minor="${minor%%.*}"patch="${1#$major.$minor.}"patch="${patch%%[-.]*}"}ee_notice(){echoechoecho"warning:$1isnowonlysupportedbydockeree"echo"checkhttps://store.docker.comforinformationondockeree"echoecho}do_install(){echo"#executingdockerinstallscript,commit:$script_commit_sha"ifcommand_existsdocker;thendocker_version="$(docker-v|cut-d''-f3|cut-d','-f1)"major_w=1minor_w=10semverparse"$docker_version"shouldwarn=0if["$major"-lt"$major_w"];thenshouldwarn=1fiif["$major"-le"$major_w"]&&["$minor"-lt"$minor_w"];thenshouldwarn=1ficat>&2<<-'eof'warning:the"docker"commandappearstoalreadyexistonthissystem.ifyoualreadyhavedockerinstalled,thisscriptcancausetrouble,whichiswhywe'redisplayingthiswarningandprovidetheopportunitytocanceltheinstallation.ifyouinstalledthecurrentdockerpackageusingthisscriptandareusingiteofif[$shouldwarn-eq1];thencat>&2<<-'eof'againtoupdatedocker,weurgeyoutomigrateyourimagestorebeforeupgradingtov1.10+.youcanfindinstructionsforthishere:https://github.com/docker/docker/wiki/engine-v1.10.0-content-addressability-migrationeofelsecat>&2<<-'eof'againtoupdatedocker,youcansafelyignorethismessage.eofficat>&2<<-'eof'youmaypressctrl+cnowtoabortthisscript.eof(set-x;sleep20)fiuser="$(id-un2>/dev/null||true)"sh_c='sh-c'if["$user"!='root'];thenifcommand_existssudo;thensh_c='sudo-esh-c'elifcommand_existssu;thensh_c='su-c'elsecat>&2<<-'eof'error:thisinstallerneedstheabilitytoruncommandsasroot.weareunabletofindeither"sudo"or"su"availabletomakethishappen.eofexit1fifiifis_dry_run;thensh_c="echo"fi#performsomeveryrudimentaryplatformdetectionlsb_dist=$(get_distribution)lsb_dist="$(echo"$lsb_dist"|tr'[:upper:]''[:lower:]')"case"$lsb_dist"inubuntu)ifcommand_existslsb_release;thendist_version="$(lsb_release--codename|cut-f2)"fiif[-z"$dist_version"]&&[-r/etc/lsb-release];thendist_version="$(./etc/lsb-release&&echo"$distrib_codename")"fi;;debian|raspbian)dist_version="$(sed's/\/.*//'/etc/debian_version|sed's/\..*//')"case"$dist_version"in9)dist_version="stretch";;8)dist_version="jessie";;7)dist_version="wheezy";;esac;;centos)if[-z"$dist_version"]&&[-r/etc/os-release];thendist_version="$(./etc/os-release&&echo"$version_id")"fi;;rhel|ol|sles)ee_notice"$lsb_dist"exit1;;*)ifcommand_existslsb_release;thendist_version="$(lsb_release--release|cut-f2)"fiif[-z"$dist_version"]&&[-r/etc/os-release];thendist_version="$(./etc/os-release&&echo"$version_id")"fi;;esac#checkifthisisaforkedlinuxdistrocheck_forked#checkifweactuallysupportthisconfigurationif!echo"$support_map"|grep"$(uname-m)-$lsb_dist-$dist_version">/dev/null;thencat>&2<<-'eof'eitheryourplatformisnoteasilydetectableorisnotsupportedbythisinstallerscript.pleasevisitthefollowingurlformoredetailedinstallationinstructions:https://docs.docker.com/engine/installation/eofexit1fi#runsetupforeachdistroaccordinglycase"$lsb_dist"inubuntu|debian|raspbian)pre_reqs="apt-transport-httpsca-certificatescurl"if["$lsb_dist"="debian"];thenif["$dist_version"="wheezy"];thenadd_debian_backport_repo"$dist_version"fi#libseccomp2doesnotexistfordebianjessiemainreposforaarch64if["$(uname-m)"="aarch64"]&&["$dist_version"="jessie"];thenadd_debian_backport_repo"$dist_version"fifi#todo:august31,2018deletefromhere,if["$lsb_dist"="ubuntu"]&&["$dist_version"="artful"];thendeprecation_notice"$lsb_dist$dist_version""august31,2018"fi#todo:august31,2018deletetohere,if!command-vgpg>/dev/null;thenpre_reqs="$pre_reqsgnupg"fiapt_repo="deb[arch=$(dpkg--print-architecture)]$download_url/linux/$lsb_dist$dist_version$channel"(if!is_dry_run;thenset-xfi$sh_c'apt-getupdate-qq>/dev/null'$sh_c"apt-getinstall-y-qq$pre_reqs>/dev/null"$sh_c"curl-fssl\"$download_url/linux/$lsb_dist/gpg\"|apt-keyadd-qq->/dev/null"$sh_c"echo\"$apt_repo\">/etc/apt/sources.list.d/docker.list"if["$lsb_dist"="debian"]&&["$dist_version"="wheezy"];then$sh_c'sed-i"/deb-src.*download\.docker/d"/etc/apt/sources.list.d/docker.list'fi$sh_c'apt-getupdate-qq>/dev/null')pkg_version=""if[!-z"$version"];thenifis_dry_run;thenecho"#warning:versionpinningisnotsupportedindry_run"else#willworkforincompleteversionsie(17.12),butmaynotactuallygrabthe"latest"ifinthetestchannelpkg_pattern="$(echo"$version"|sed"s/-ce-/~ce~.*/g"|sed"s/-/.*/g").*-0~$lsb_dist"search_command="apt-cachemadison'docker-ce'|grep'$pkg_pattern'|head-1|cut-d''-f4"pkg_version="$($sh_c"$search_command")"echo"info:searchingrepositoryforversion'$version'"echo"info:$search_command"if[-z"$pkg_version"];thenechoecho"error:'$version'notfoundamongstapt-cachemadisonresults"echoexit1fipkg_version="=$pkg_version"fifi(if!is_dry_run;thenset-xfi$sh_c"apt-getinstall-y-qq--no-install-recommendsdocker-ce$pkg_version>/dev/null")echo_docker_as_nonrootexit0;;centos|fedora)yum_repo="$download_url/linux/$lsb_dist/$repo_file"if!curl-ifs"$yum_repo">/dev/null;thenecho"error:unabletocurlrepositoryfile$yum_repo,isitvalid?"exit1fiif["$lsb_dist"="fedora"];thenif["$dist_version"-lt"26"];thenecho"error:onlyfedora>=26aresupported"exit1fipkg_manager="dnf"config_manager="dnfconfig-manager"enable_channel_flag="--set-enabled"pre_reqs="dnf-plugins-core"pkg_suffix="fc$dist_version"elsepkg_manager="yum"config_manager="yum-config-manager"enable_channel_flag="--enable"pre_reqs="yum-utils"pkg_suffix="el"fi(if!is_dry_run;thenset-xfi$sh_c"$pkg_managerinstall-y-q$pre_reqs"$sh_c"$config_manager--add-repo$yum_repo"if["$channel"!="stable"];then$sh_c"$config_manager$enable_channel_flagdocker-ce-$channel"fi$sh_c"$pkg_managermakecache")pkg_version=""if[!-z"$version"];thenifis_dry_run;thenecho"#warning:versionpinningisnotsupportedindry_run"elsepkg_pattern="$(echo"$version"|sed"s/-ce-/\\\\.ce.*/g"|sed"s/-/.*/g").*$pkg_suffix"search_command="$pkg_managerlist--showduplicates'docker-ce'|grep'$pkg_pattern'|tail-1|awk'{print\$2}'"pkg_version="$($sh_c"$search_command")"echo"info:searchingrepositoryforversion'$version'"echo"info:$search_command"if[-z"$pkg_version"];thenechoecho"error:'$version'notfoundamongst$pkg_managerlistresults"echoexit1fi#cutouttheepochandprefixwitha'-'pkg_version="-$(echo"$pkg_version"|cut-d':'-f2)"fifi(if!is_dry_run;thenset-xfi$sh_c"$pkg_managerinstall-y-qdocker-ce$pkg_version")echo_docker_as_nonrootexit0;;esacexit1}#wrappedupinafunctionsothatwehavesomeprotectionagainstonlygetting#halfthefileduring"curl|sh"do_install
chmod+xgetdocker.sh./getdocker.sh-sdocker--mirroraliyun

getdocker.sh 文件内容在上个代码区域

 </div> <div class="zixun-tj-product adv-bottom"></div> </div> </div> <div class="prve-next-news">
本文:怎么干净的卸载docker的详细内容,希望对您有所帮助,信息来源于网络。
上一篇:怎么利用docker部署nextcloud网盘下一篇:

3 人围观 / 0 条评论 ↓快速评论↓

(必须)

(必须,保密)

阿狸1 阿狸2 阿狸3 阿狸4 阿狸5 阿狸6 阿狸7 阿狸8 阿狸9 阿狸10 阿狸11 阿狸12 阿狸13 阿狸14 阿狸15 阿狸16 阿狸17 阿狸18